gpt4 book ai didi

asp.net - 向下拉列表添加额外选项

转载 作者:行者123 更新时间:2023-12-04 18:22:28 24 4
gpt4 key购买 nike

我有一个从 sqldatasource 填充的 asp.net 下拉列表。我的问题是第一个选项必须是(全部)。无论如何要在 eqldatasource 列表之前将此额外选项添加到列表中?

     <asp:DropDownList ID="REGIONS" runat="server" 
Width="70px" AutoPostBack="True" DataTextField="REGION_CD"
DataValueField="REGION_CD" DataSourceID="SqlDataSource1" >
</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PRODUCTION %>"
ProviderName="<%$ ConnectionStrings:PRODUCTION.ProviderName %>"
SelectCommand="select distinct(region_cd) from mv_gauge_filter_dist where region_cd is not null">
</asp:SqlDataSource>

谢谢!

最佳答案

未经测试,但这应该可以工作:

<asp:DropDownList ID="REGIONS" AppendDataBoundItems="true" runat="server" 
Width="70px" AutoPostBack="True" DataTextField="REGION_CD"
DataValueField="REGION_CD" DataSourceID="SqlDataSource1" >
<asp:ListItem Text="ALL" Value="" />
</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PRODUCTION %>"
ProviderName="<%$ ConnectionStrings:PRODUCTION.ProviderName %>"
SelectCommand="select distinct(region_cd) from mv_gauge_filter_dist where region_cd is not null">
</asp:SqlDataSource>

记下 AppendDataBoundItems="true"...

关于asp.net - 向下拉列表添加额外选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10387577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com