在Datagridview中设置ComboBox的显示文本 [英] Set Display Text Of ComboBox In Datagridview
问题描述
如何将Datagridview中组合框的显示文本设置为例如:单击此处打开下拉列表"
在组合框中设置文本很简单,但将文本设置为Datagridviewcombobox不像combobox
找到有用链接的任何人都请帮助我,因为我没有找到与我的问题相关的任何链接
我的意思是,我想在用户单击之前在组合框中显示文本
已
我想我没有很好地解释我的问题,请看这张图片:
没有显示文本的组合框 [带有显示文字的组合框 [
How to Set Display Text Of ComboBox In Datagridview to for example :"Click Here To Open Drop Down List"
Set Text In Combo Box Is Simple but Set Text To Datagridviewcombobox is not like combobox
Any One Who Found Useful Link please help me,because i didnt find any link related to my problem
I mean,i want to show a text in combo box before user click on it
Edited:
I think i didnt explained my question well,see this picture please:
combo box without display text[^]
and this picture :
combo box with display text[^]
i want to make my combo box like second picture(i want to show an string like : "click here to open drop down list" in combo box before user click)
推荐答案
亲爱的
如果要从数据库中获取组合的数据,则可以使用联合查询来选择选择组合框",例如
hi dear
If you are fetching data for combo from database then you can use union query for select "Select combobox" like
select Val,Txt from tblComboMaster
union All
select '0' as Val, 'Select combobox' as Txt
order by Val
绑定组合框中的选定值= 0后,
谢谢
after it bind selected value = 0 from combobox
Thanks
您好,
检查此
Hi ,
Check this
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
onrowdeleting="GridView1_RowDeleting">
<Columns>
<asp:BoundField DataField="dd" HeaderText="dd" SortExpression="dd" />
<asp:TemplateField HeaderText="ddd" SortExpression="ddd">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ddd") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ddd") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="cate" SortExpression="cate">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource12" DataTextField="cate" DataValueField="id"
SelectedValue="<%# Bind('cate') %>">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource12" runat="server"
ConnectionString="<%
ConnectionStrings:testConnectionString SelectCommand =" > < /asp:SqlDataSource > < /EditItemTemplate > < ItemTemplate > < asp:Label ID =" runat 服务器" 文本 <%#Bind(" )%> ' > < /asp:Label > < /ItemTemplate > < /asp:TemplateField > < asp:CommandField ShowEditButton =" / < /列 > < /asp:GridView > < asp:SqlDataSource ID =" runat 服务器" span> ConnectionString =" <%
ConnectionStrings:testConnectionString %>" SelectCommand="SELECT * FROM [cate]"></asp:SqlDataSource> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("cate") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%
这篇关于在Datagridview中设置ComboBox的显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!