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
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