如何防止从GridView ItemTemplate的组合框中重复输入 [英] how to prevent duplicate entry from combobox in gridview itemtemplate
本文介绍了如何防止从GridView ItemTemplate的组合框中重复输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何防止在gridview itemtemplate(即gridview的第一列)中的组合框中重复输入?如何检查combobobox的选择范围?
how to prevent duplicate entry from combobox in gridview itemtemplate which is first column of gridview? how i can check already selection has done from combobobox?
<asp:TemplateField HeaderText="Item" ItemStyle-Height ="10px">
<ItemTemplate>
<asp:ComboBox ID="cbaccount" runat="server" DataSourceID="SqlDataSource5" DataTextField="itemname" AutoPostBack="true" onkeyup=" UnHighlight(this)"
DataValueField="itemid" Width="180px" AutoCompleteMode="SuggestAppend" CssClass="WindowsStyle cb" DropDownStyle="DropDownList" AppendDataBoundItems="True" OnSelectedIndexChanged="cbaccount_SelectedIndexChanged" >
<asp:ListItem Selected="True" Text=""></asp:ListItem>
</asp:ComboBox>
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionASPX %>"
SelectCommand="SELECT [itemname],[itemid] FROM [itemadd] ORDER BY [itemname]">
</asp:SqlDataSource>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="HeaderStyle1" />
<ItemStyle Width="180px" />
</asp:TemplateField>
推荐答案
ConnectionStrings:ConnectionASPX%>" span> SelectCommand 选择[itemname],[itemid]从[itemadd]排序,然后按[itemname]" > < /asp:SqlDataSource > < /ItemTemplate > < HeaderStyle =" 左" CssClass HeaderStyle1" / > < ItemStyle =" 180px" > < /asp:TemplateField >
ConnectionStrings:ConnectionASPX %>" SelectCommand="SELECT [itemname],[itemid] FROM [itemadd] ORDER BY [itemname]"> </asp:SqlDataSource> </ItemTemplate> <HeaderStyle HorizontalAlign="Left" CssClass="HeaderStyle1" /> <ItemStyle Width="180px" /> </asp:TemplateField>
将您的SELECT更改为:
SelectCommand ="SELECT DISTINCT [项目名称],[itemid]来自[itemadd] ORDER BY [[项目名称]">
Change your SELECT as :
SelectCommand="SELECT DISTINCT [itemname],[itemid] FROM [itemadd] ORDER BY [itemname]">
这篇关于如何防止从GridView ItemTemplate的组合框中重复输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文