Problems with SelectedIndexChanged asp.net C #

2

I added in the method where the list comes from the database:

ddlSalas.Items.Insert(0, new ListItem("TODAS", ""));

When I choose this option "ALL" in dropdownlist , a post on the page happens but it does not call the selectedindexchanged event that contains the method that will load a gridview with the information.

What can be happening? What did I do wrong?

    
asked by anonymous 11.06.2015 / 20:16

2 answers

1

What is the initial data of the combo? Is it already the All ? How about using a ddlSalas.Items.Insert (-1, new ListItem ("Select", "")); before the ddlSalas.Items.Insert (0, new ListItem ("ALL", "")); ? Does it work?

    
18.06.2015 / 21:09
2

Well strange, it was supposed to work, if the generated of your file correctly generated the assignment of the event to your dropdownlist, but beauty, to ensure that your method is called, try to put after adding the items in the list this command:

dropdownlist.SelectedIndexChanged += new EventHandler(dropdownlist_SelectedIndexChanged);
    
11.06.2015 / 21:52