Loading Combo from XSD

Y

Yama

Hi,

I have created a dataset (xsd) to pull data from two tables from a stored
procedure.

Step 1:
CREATE PROCEDURE getComboBoxItems AS
SELECT ID, Description FROM EmployeeStatus
SELECT ID, Description FROM EmployeeType

Step 2:
I created a new XSD file. I draged the stored procedure which automatically
created the tables.

Step 3:
public dsComboBoxItems GetComboBoxItems()
{
DataAccess.dsComboBoxItems ds = new DataAccess.dsComboBoxItems();
try
{
SqlDataAdapter da = new
SqlDataAdapter("GetComboBoxItems",sqlConnection);
da.SelectCommand.CommandType = CommandType.StoredProcedure;

// Create table mappings
da.TableMappings.Add("Table", "EmployeeStatus");
da.TableMappings.Add("Table1", "EmployeeType");
// Fill the dataset
da.Fill(ds);
}
catch (Exception ex){}

return ds;
}



I would like to like to populate two combo boxes. How can I do this? I
tried:

cboEmployeeType.Items.Clear();
dsEmployeeType = DAC.GetComboBoxItems();

cboEmployeeType.DataSource = cboEmployeeType.Tables["EmployeeType"];
cboEmployeeType.DataTextField =
cboEmployeeType.Tables["EmployeeType"].Columns["Description "].ToString();
cboEmployeeType.DataValueField =
cboEmployeeType.Tables["EmployeeType"].Columns["ID"].ToString();
cboEmployeeType.DataBind();

Similarly I do the same with the EmployeeStatus combobox (dropdown box).

Alas I am getting no returned value data from the database although I have
many records in them.
What do I ned to do to fill the comboboxes?

Thanks,


Yama
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top