【发布时间】:2013-06-18 17:29:37
【问题描述】:
我有几个简单的下拉列表。第一个由 html 中的 linqdatsource 绑定,autopostback 设置为 true。第一个的选择决定了第二个中的数据。当我首先选择一个项目时, selectedindexChanged 事件会触发;但是,所选值始终是列表中的第一项,然后列表重新绑定并恢复到其默认状态。我是否必须在代码隐藏中绑定它以防止这种情况?
<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中的值?是在后面的代码里吗? -
该列表在 dd_shirtlist 控件的 selectedindexchanged 事件期间绑定在代码隐藏中。我在加载事件中没有任何内容
-
我相信问题可能出在那个代码上。您能否edit您的帖子并向我们展示该活动期间发生的情况?
-
我已经将代码注释掉了,没有任何变化。
标签: asp.net drop-down-menu autopostback