this is your previous code:
public void FillActivityWaterStorage()
{
try
{
dt = Query.Guindy_ActivityWaterStorage_Population();
if (dt.Rows.Count > 0)
{
ddl_ActivityWaterStorage.Items.Clear();
ddl_ActivityWaterStorage.DataTextField = "ActivityName";
ddl_ActivityWaterStorage.DataValueField = "ActivityID";
ddl_ActivityWaterStorage.DataSource = dt;
ddl_ActivityWaterStorage.DataBind();
ddl_ActivityWaterStorage.Items.Insert(0, new ListItem("--SELECT--"));
}
else
{ ddl_SubActivityWaterStorage.Items.Insert(0, new ListItem("--SELECT--"));
}
}
catch { }
}
you do work around here. . . add item in your DropDownList2 jsut like you did in dropdownList1
ddl.Items.Insert(0,"--");
now for the ddl selected changed:
public void ddl_ActivityWaterStorage_SelectedChanged(Sender object,EventArguments e)
{
if(ddl_ActivityWaterStorage.SelectedValue==The2nditem)
{
ddl_SubActivityWaterStorage.DataSource=PopulateDataFromDatabase;
ddl_SubActivityWaterStorage.DataBind();
}
else
{
ddl_SubActivityWaterStorage.DataSource=null;
ddl_SubActivityWaterStorage.DataBind();
}
}
hope it will work,comment if got error or something wrong so I can check the code again :)