如何在GridView中默认显示下拉菜单中的选择 [英] how to display select in dropdown by default in gridview
本文介绍了如何在GridView中默认显示下拉菜单中的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在网格视图中设置选择" HardCode第一值下拉菜单.
<asp:TemplateField HeaderText="Professional Role"> <itemtemplate> <asp:DropDownList runat="server" ID="ddlProfRole" width="87%" DataValueField="ProfRoleCode" DataSourceID="SqlDataSource2" DataTextField="ProfRoleDescription"> </itemtemplate> <itemstyle horizontalalign="Center" width="25%" /> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ConnectionStrings:MPP%>" SelectCommand="select ProfRoleCode,ProfRoleDescription,Designcode,DeptID from mppProfRoleMapping order by ProfRoleCode">
问候,
Ganesh.S
解决方案
ConnectionStrings:MPP%> SelectCommand =从ProfppoleCode的mppProfRoleMapping顺序中选择ProfRoleCode,ProfRoleDescription,Designcode,DeptID">
问候,
Ganesh.S
您好,
在关闭您的dropdownlistcontrol
之前添加此代码 < asp:ListItem Text ="Select" Value =-1"></asp:ListItem>
希望对您有帮助
谢谢
sanjeev
使用属性AppendDataBoundItems
<asp:dropdownlist runat="server" id="ddlProfRole" width="87%" datavaluefield="ProfRoleCode" datasourceid="SqlDataSource2" datatextfield="ProfRoleDescription" appenddatabounditems="true" xmlns:asp="#unknown"> <asp:listitem text="ALL" value="" /> </asp:dropdownlist>
进一步阅读
ASP.NET中的ListControl.AppendDataBoundItems属性 [<asp:TemplateField HeaderText="Professional Role"> <itemtemplate> <asp:DropDownList runat="server" ID="ddlProfRole" width="87%" DataValueField="ProfRoleCode" DataSourceID="SqlDataSource2" DataTextField="ProfRoleDescription"> </itemtemplate> <itemstyle horizontalalign="Center" width="25%" /> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ConnectionStrings:MPP%>" SelectCommand="select ProfRoleCode,ProfRoleDescription,Designcode,DeptID from mppProfRoleMapping order by ProfRoleCode">
Regards,
Ganesh.S解决方案ConnectionStrings:MPP%>" SelectCommand="select ProfRoleCode,ProfRoleDescription,Designcode,DeptID from mppProfRoleMapping order by ProfRoleCode">
Regards,
Ganesh.S
Hello,
add this before closing ur dropdownlistcontrol
<asp:ListItem Text="Select" Value="-1" ></asp:ListItem>
hoping it will help you
thanks
sanjeev
Use the propertyAppendDataBoundItems
<asp:dropdownlist runat="server" id="ddlProfRole" width="87%" datavaluefield="ProfRoleCode" datasourceid="SqlDataSource2" datatextfield="ProfRoleDescription" appenddatabounditems="true" xmlns:asp="#unknown"> <asp:listitem text="ALL" value="" /> </asp:dropdownlist>
Further reading
ListControl.AppendDataBoundItems Property in ASP.NET[^]
这篇关于如何在GridView中默认显示下拉菜单中的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文