如何使用sqlDatasource显示下拉列表的标题 [英] How to Show Title of Dropdown list by using sqlDatasource

查看:71
本文介绍了如何使用sqlDatasource显示下拉列表的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,所有

我使用SqlDatasoure在下拉列表中显示项目。所以,我的问题是如何在我从SqlDatasource查询项目列表之前显示标题选择级别?



再次感谢您的帮助

解决方案

您好,

检查这个

 <   div  >  
< asp:DropDownList ID = DropDownList1 runat = server AppendDataBoundItems =

ValidationGroup = ss DataSourceID = SqlDataSource1 DataTextField = 名称

DataValueField = productID >
< asp:ListItem 文本 = ---选择--- = 0 > < / asp:ListItem >


< / asp:DropDownList >
< asp:SqlDataSource ID = SqlDataSource1 runat = server < span class =code-attribute>

< span class =code-attribute> ConnectionString = <%


ConnectionStrings:testConnectionString%>

< span class =code-attribute> SelectCommand = SELECT [productID],[name] F. ROM [产品] >
< / asp:SqlDataSource >
< < span class =code-leadattribute> / div >



最好的问候

M.Mitwalli


对于此类标题,请使用控件 System.Web.UI.WebControls.Label

http://msdn.microsoft。 com / en-us / library / system.web.ui.webcontrols.label.aspx [ ^ ]。



-SA

Dear, All
I use SqlDatasoure for showing item on dropdownlist. So, My question is "How to show the title like "Select Level" before the item list i have query from SqlDatasource?"

Appreciated for your kindly help again

解决方案

Hi ,
Check this

    <div>
    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"

    ValidationGroup="ss" DataSourceID="SqlDataSource1" DataTextField="name" 

            DataValueField="productID">
<asp:ListItem Text="---select---" Value="0" ></asp:ListItem>
 
 
</asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 

            ConnectionString="<%


ConnectionStrings:testConnectionString %>" SelectCommand="SELECT [productID], [name] FROM [Product]"> </asp:SqlDataSource> </div>


Best Regards
M.Mitwalli


For such title, use the control System.Web.UI.WebControls.Label:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.label.aspx[^].

—SA


这篇关于如何使用sqlDatasource显示下拉列表的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆