【发布时间】:2011-05-24 09:12:10
【问题描述】:
有一个与数据源绑定的下拉列表 -> 称为此 DropDownList A 此数据源从另一个下拉列表中获取另一个参数 -> 称为此 DropDownList B
每次 DropDownList B 改变选中的值,Dropdownlist A 的 Datasource 都会接收到参数并改变 dropdownlist A。
每当 DropDownlist 更改其索引时,都会导致回发,并且所选值将重置为第一个索引(默认)。
在切换 DropDownList A 以使用不带参数的数据源之后。不会出现此问题。 DropDownList A 改变了它的值并回发后,最近改变的值仍然存在。
我已经尝试使用更新面板,但它仍然无法正常工作。
这是 DropDownList B,添加类型
<asp:DropDownList ID="ddlAddOnType" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" ClientIDMode="Static" CssClass="controlOrdinary"
DataSourceID="odsAddOnType" DataTextField="AddOnTypeName"
DataValueField="AddOnTypeId"
onselectedindexchanged="ddlAddOnType_SelectedIndexChanged" Width="208px">
<asp:ListItem Value="0">--Please Select--</asp:ListItem>
</asp:DropDownList>
这是 dropDownlist A 的数据源
<asp:ObjectDataSource ID="odsAddon" runat="server"
SelectMethod="SelectAddOnThatIsNotInCurrentPromotionWithAddOnByAddOnTypeId"
TypeName="BackOfficeLib.SupportAdmin.PromotionBinder">
<SelectParameters>
<asp:ControlParameter ControlID="ddlAddOnType" Name="pIntAddOnTypeId"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
这是下拉列表A,当这个改变值时,页面突然回传,索引被重置。
<asp:DropDownList ID="ddlAddOn" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" ClientIDMode="Static" CssClass="controlOrdinary"
DataTextField="AddOnName" DataValueField="AddOnId"
onselectedindexchanged="ddlAddOn_SelectedIndexChanged" Width="208px">
<asp:ListItem Value="0">--Please Select--</asp:ListItem>
</asp:DropDownList>
【问题讨论】: