我想在dropwnlist的零元素中显示选择项 [英] i want to display select item in zero element in dropwnlist

查看:55
本文介绍了我想在dropwnlist的零元素中显示选择项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我与数据库的dropwnlist绑定时,我想将选择项添加到dropdownlist第零个元素中

i want to add the select item in dropdownlist zero''th element when i dound with that dropwnlist with the database
how it can be possible

推荐答案

你好Reshma,

在将下拉列表与数据库绑定后,只需尝试一下即可.

hello Reshma,

just try this after binding the dropdownlist with database.

ddl.Items.Insert(0, new ListItem("-Select-", "0"));



希望对您有帮助.
并且,如果有帮助,别忘了将其标记为答案. :)



Hope this will help you.
And don''t forget to mark as answer if it helps. :)




试试这个,


Hi,

try with this,


<asp:dropdownlist id="DropDownList1" runat="server" width="200px" xmlns:asp="#unknown">
            AppendDataBoundItems="true" DataSourceID="sdsdropdown" DataTextField="Name" 
             DataValueField="Id">
         </asp:dropdownlist>







<asp:SqlDataSource ID="sdsdropdown" runat="server" 

                            ConnectionString="<%


ConnectionStrings:ConnectionStringname%>" span> SelectCommand =" 从[表]中选择[Id],[名称]" < /asp:SqlDataSource >
ConnectionStrings:ConnectionStringname %>" SelectCommand="SELECT [Id], [Name] FROM [table]"> </asp:SqlDataSource>















or

<asp:dropdownlist id="DropDownList1" runat="server" width="200px" xmlns:asp="#unknown">
              DataSourceID="sdsdropdown" DataTextField="Name" 
             DataValueField="Id">
         </asp:dropdownlist>



<asp:sqldatasource id="sdsdropdown" runat="server" connectionstring="<%


这篇关于我想在dropwnlist的零元素中显示选择项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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