Cascading dropdown list not rebinding values on postback
I have a problem with which I've been coping for the past hour without any
success.
Actually, the thing is quite easy. I have couple of dropdownlists: couple
that have data binded only on first page load and the other one that also
has data binded on first page load with difference that its data on
postback depends of the selection (if something is selected) of the other
dropdownlists.
protected void ddlArticleCategories_Load(object sender, EventArgs e)
{
var articleCategories = helper.GetPrimaryArticleCategories(db);
if (ddlLanguage.SelectedIndex > 0)
{
int idLanguage = Convert.ToInt32(ddlLanguage.SelectedValue);
articleCategories = articleCategories.Where(ac =>
ac.idLanguage == idLanguage).ToList();
}
if (ddlUsergroup.SelectedIndex > 0)
{
int idUsergroup = Convert.ToInt32(ddlUsergroup.SelectedValue);
articleCategories = articleCategories.Where(ac =>
ac.idUsergroup == idUsergroup).ToList();
}
ddlArticleCategories.DataSource = articleCategories;
ddlArticleCategories.DataBind();
}
The problem is that on postback no data is binded to the second
dropdownlist even though datasource contains data.
Any help would be appreciated. Thank you!
No comments:
Post a Comment