我已经创建了 Web 应用程序,我想使用两个下拉列表。当我从下拉列表中选择一些值时,它会影响下拉列表 2,但是第一次绑定的值不清楚,任何人都可以帮助我
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Select sel_obj = new Select();
#region Load Department Name
if (departchk.Checked==true && DropDownList1.SelectedIndex==1)
{
DataTable DT = sel_obj.select_Dept_Name();
recordddl.DataSource = DT;
recordddl.DataTextField = "Department_Name";
//departmentDrop.DataValueField = "Department_ID";
recordddl.DataBind();
recordddl.Items.Insert(0, new ListItem("--Select--", "0"));
}
#endregion
#region Load Employee Name
else if(departchk.Checked==true && DropDownList1.SelectedIndex==2)
{
DataTable DS = sel_obj.select_Emp_Name();
recordddl.DataSource = DS;
recordddl.DataTextField = "Employee_Name";
recordddl.DataBind();
recordddl.Items.Insert(0, new ListItem("--Select--", "0"));
}
#endregion
#region Load Location Name
else if(departchk.Checked==true && DropDownList1.SelectedIndex==3)
{
DataTable DD2 = sel_obj.select_Location_Name();
recordddl.DataSource = DD2;
recordddl.DataTextField = "Location_Name";
recordddl.DataBind();
recordddl.Items.Insert(0, new ListItem("--Select--", "0"));
}
#endregion
}