I have a couple of straightforward dropdownlists. The first is bound by a linqdatsource in the html with autopostback set to true. The selection of the first determines the data in the second. When I select an item in the first, the selectedindexChanged event fires; however, the selected value is always the first item in the list and the list then re-binds and reverts to its default state. Do I have to bind it in code-behind to prevent this?
<asp:DropDownList ID="dd_shirtcolor" runat="server" AppendDataBoundItems="true" AutoPostBack="True">
<asp:ListItem Text="Select Color" />
</asp:DropDownList>
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="IPC.IPCDataDataContext" EntityTypeName=""
TableName="Shirts" Where="IsActive == @IsActive">
<WhereParameters>
<asp:Parameter DefaultValue="true" Name="IsActive" Type="Boolean" />
</WhereParameters>
</asp:LinqDataSource>
Some alternatives to managing cascading drop down lists yourself are:
ASP.NET AJAX Control Toolkit: ASP.NET AJAX Cascading Drop Down
Cascading Drop Down Using ASP.NET and jQuery: Cascading Drop Down Using ASP.NET And jQuery