I have one dropdownlist and one button and listview. Button and dropdownlist is outside listview. On 1st page load, all the item is displayed. Now user can see based on selection of dropdownlist and i am binding the listview on click of the button after selecting the item from dropdownlist.
I want to show selected text of dropdownlist in lable of layout control of listview.
I wrote below code but doesn't seem to work correctly.
protected void lvProduct_LayoutCreated(object sender, EventArgs e) { if (dlCategory.SelectedIndex != -1) { string Category= dlCategory.SelectedItem.Text.ToString(); (lvProduct.FindControl("lblCategory") as Label).Text = "Category: " + dlCategory.SelectedItem.Text.ToString(); } else { (lvProduct.FindControl("lblCategory") as Label).Text = "All category"; } }
What could be the reason? I do see that as soon as i click the button, the listview_LayoutCreated is fired.