Saturday, March 24, 2012

DropDownList SelectedIndexChanged not fire (Autopostback - true!)

1<asp:DropDownList ID="SectionsDDL" runat="server" DataSourceID="SectionsObDS"2AutoPostBack="True" OnSelectedIndexChanged="SectionsDDL_SelectedIndexChanged"3DataTextField="titleName" DataValueField="id">4</asp:DropDownList>56<asp:UpdatePanel ID="UpdatePanel1" runat="server">7<ContentTemplate>8<asp:Panel ID="sectData" runat="server">9<asp:Label ID="tstlbl" runat="server" />10</asp:Panel>11</ContentTemplate>12<Triggers>13<asp:AsyncPostBackTrigger ControlID="sectionsDDL" EventName="SelectedIndexChanged" />14</Triggers>15</asp:UpdatePanel>

Everything is ok when I choose any item in DDL but first. When I choose first SelectedIndexChanged not fire.

I tried to find answer on forum and could not.

it sounds like your first item is selected when the dropdown loads so if you pick that answer the selected index never changes. Try adding an additional item called Not Selected or choos one or something along those lines as the first item in the list then everytime you should postback.

AjaxButter


Or you could change the SelectedIndex property to -1

No comments:

Post a Comment