HI
I have dropdownlists in register.aspx page
1- ddlzoneE 2-DdlDistrictE
I bind them from database
and when I select item from ddlzoneE , ddlDistrictE's Item change below are code
protected void DDLzoneE_SelectedIndexChanged(object sender, EventArgs e)
{
BindDistrictE();
}
private void BindDistrictE()
{
DdlDistrictE.Items.Clear();
DdlDistrictE.Items.Add(new ListItem("ALL", ""));
DdlDistrictE.AppendDataBoundItems = true;
SqlCommand _cmd = new SqlCommand("selectdistrict", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.AddWithValue("@RegionID", ddlzoneE.SelectedItem.Text);
_cn.Open();
DdlDistrictE.DataSource = _cmd.ExecuteReader();
DdlDistrictE.DataTextField = "District";
DdlDistrictE.DataValueField = "ID";
DdlDistrictE.DataBind();
_cn.Close();
}
untill now every thing is ok and when I select Item from ddlzoneE ,DdlDistrict's Item change but when I add below code in Page_load Event it didn't worked
ddlzoneE.Items.FindByText(_dr["zone"].ToString()).Selected = true;
DdlDistrictE.Items.FindByText(_dr["District"].ToString()).Selected = true;
I mean when I add above code when I select item from ddlzoneE , ddldistrict's Item didn't change
what should I do?
Best Regards
Neda