某些背景:我在母版页上有一个下拉列表,用户可以用来选择公司的其他区域. 在gridview页面上,我基于网站上的一些代码设置了一个过滤器: demo.evonet. au/GridviewwithFiltering.aspx [ ^ ] 我遇到的问题是,当用户更改母版页上的区域时,下拉列表将填充该区域的新值,并且还保留先前区域的值. 示例:区域A:AA,AB,AC下拉列表将仅显示那些项目.当用户选择区域B:BB,BC,BD时,下拉列表将显示BB,BC,BD,AA,AB,AC. 如何防止这种情况? 这是gridview页面上的下拉列表:
Some background: I have a dropdownlist on a master page that the user can use to select a different area of a business. On a gridview page I have set up a filter based on some code from the site: demo.evonet.au/GridviewwithFiltering.aspx[^] The issue I have is when a user changes the area on the master page the dropdownlist gets populate with the new values for the area and also retains the values from the previous Area. Example: Area A: AA, AB, AC the dropdownlist will only show those items. when the user selects Area B: BB, BC, BD the drop down will show BB, BC, BD, AA, AB, AC. How do I prevent this? Here is the Dropdownlist on the gridview page:
<asp:DropDownList ID="ddlLastName" DataSourceID="SqlDataSource2" AutoPostBack="True" DataValueField="LastName" runat="server" Width="120px" Font-Size="11px" AppendDataBoundItems="True" DataTextField="LastName"> <asp:ListItem Text="All" Value="%"></asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:XXXConnectionString %>" SelectCommand="SELECT [LastName] FROM [Names] WHERE ([Site] = @Site) ORDER BY [LastName]"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" Name="Site" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource>推荐答案
ConnectionStrings:XXXConnectionString %> " SelectCommand =" 从[名称]的位置([站点] = @站点)中选择[姓氏]或按[姓氏]排序" > < SelectParameters > < asp:ControlParameter ControlID =" TextBox1" 名称 =" 网站" span> PropertyName =" 文本" 类型 =" 字符串" / > < /SelectParameters > < /asp:SqlDataSource > ConnectionStrings:XXXConnectionString %>" SelectCommand="SELECT [LastName] FROM [Names] WHERE ([Site] = @Site) ORDER BY [LastName]"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" Name="Site" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource>
嗨 从下拉列表中删除 Hi Remove AppendDataBoundItems="True"
年龄,然后尝试. 希望这会有所帮助.
tage from your dropdownlist and try. Hope this helps.
更多推荐
在主页上更改dropdownlist时,dropdownlist为双精度值
发布评论