BOEING39
asked on
SRTING DROPDOWN LIST
Please review code below. I need to sort the data in dropdown lists for "CondBY" and "InspBy" in "ASCENDING ORDER" or alphabetical order. I need assistance with this code.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillDropdown(CondBY);
FillDropdown(InspBy1);
}
}
con.Open();
SqlCommand cmd = new SqlCommand("select * from EmpData", con);
SqlDataAdapter dap = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
dap.Fill(ds);
ddl.DataSource = ds;
ddl.DataTextField = "Name1";//Database table filed name for display in dropdown
ddl.DataValueField = "EmpNo";//display in textbox when select dropdown field
ddl.DataBind();
}
protected void CondBY_SelectedIndexChanged(object sender, EventArgs e)
{
EmpAP.Text = CondBY.SelectedValue.ToString();// get value form dropdown
}
protected void InspBy1_SelectedIndexChanged(object sender, EventArgs e)
{
EmpAP1.Text = InspBy1.SelectedValue.ToString();// get value form dropdown
}
}
If you are getting that data from the database, then you could sort it there.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Researched solution on the web. Statement solution was the best explanation and associated code to resolve problem.