Hi
First of all you have to fill
Requesters drop down your code is like
Page_Load()
{
SQL = "SELECT DISTINCT DepartmentID,Department FROM Requesters"
SQLDataAdapter da = new SQLDataAdapter(SQL, connection);
DataSet ds = new DataSet();
da.Fill(ds);
drpRequesters.DataTextField = "Department";
drpRequesters.DataValueField = "DepartmentID";
drpRequesters.DataSource = ds.Tables[0];
drpRequesters.DataBind();
FillLocation();
}
Now you have to fill
Location drop down
based on Department selection
private void FillLocation()
{
if(drpRequesters.SelectedIndex >= 0)
{
drpLocation.Items.Clear();
SQL = "SELECT DISTINCT LocationID,Location FROM Locations WHERE DepartmentID=" + drpRequesters.SelectedItem.Value;
SQLDataAdapter da = new SQLDataAdapter(SQL, connection);
DataSet ds = new DataSet();
da.Fill(ds);
drpLocation.DataTextField = "Location";
drpLocation.DataValueField = "LocationID";
drpLocation.DataSource = ds.Tables[0];
drpLocation.DataBind();
}
}
Final step is you have create
change event of Dipartment like
drpDepartment_SelectedIndexChanged()
{
FillLocation();
}
You should set
AutoPostback="True"
for drpDepartment from .aspx page
Thanks,
Imdadhusen