我有幾個簡單的下拉列表。第一個被綁定在html中的一個linqdatsource,autopostback設置爲true。第一個選擇決定第二個數據。當我在第一個選擇一個項目時,selectedindexChanged事件觸發;但是,所選值始終是列表中的第一項,然後該列表將重新綁定並恢復爲默認狀態。我是否必須在代碼隱藏中綁定它才能防止這種情況發生?Dropdownlist在autopostback期間丟失了價值
<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>
我最近有類似DropDownLists這樣的問題。你如何確定'dd_shirtcolor'中的值?它是否在代碼背後? – wlyles
該列表在dd_shirtlist控件的selectedindexchanged事件期間綁定在代碼隱藏中。我沒有任何東西在加載事件 – DoImagine
我相信問題可能在於該代碼。你可以[編輯](http://stackoverflow.com/posts/17175223/edit)你的帖子,並告訴我們在這個事件發生了什麼? – wlyles