Reputation: 129
In the following code everytime its taking only one item from dropdownlist. When I select any other item from dropdownlist its same as first item.
Please give solution
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet _subcat = new DataSet();
_subcat = serviceus.Get_SERVICEUS_SUB_CATEGORYLIST(DropDownList1.SelectedValue.ToString());
lbsubcategory.DataSource = _subcat.Tables[0].DefaultView;
lbsubcategory.DataTextField = Convert.ToString(_subcat.Tables[0].Columns["CATEGORY_SUB1_NAME"].ColumnName);
lbsubcategory.DataBind();
Label5.Visible = true;
}
Upvotes: 0
Views: 1810
Reputation: 389
EnableViewState="False" on the lbsubcategory.
Assuming AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
Upvotes: 0
Reputation: 48088
Check how you bind your dropdownlist. I think you're binding it everytime your page posts back to server. Try to use IsPostBack property of the page :
if (!IsPostBack){
DropDownList1.DataSource = datasource;
DropDownList1.DataBind();
}
Upvotes: 1
Reputation: 6765
Do you have:
if(!IsPostBack) {
DataBind();
}
around your initial databind (eg in OnLoad)
Upvotes: 0