Asp.net 仍然没有得到解决方案…有人能帮我吗?

Asp.net 仍然没有得到解决方案…有人能帮我吗?,asp.net,c#-4.0,Asp.net,C# 4.0,我有ddl和textbox。若我的文本框值已经存在于ddl中,则意味着我应该将消息显示为已经存在于ddl中 我试过比较calidator…但不起作用 <asp:DropDownList ID="ddlmothertongue" AppendDataBoundItems="True" runat="server" CssClass="dd_NoWidth" Width="136px" OnSelectedIndexChanged="ddlmother

我有ddl和textbox。若我的文本框值已经存在于ddl中,则意味着我应该将消息显示为已经存在于ddl中

我试过比较calidator…但不起作用

<asp:DropDownList ID="ddlmothertongue" AppendDataBoundItems="True" runat="server"
          CssClass="dd_NoWidth" Width="136px" 
          OnSelectedIndexChanged="ddlmothertongue_SelectedIndexChanged"
          AutoPostBack="True" DataSourceID="SqlDataSource1" 
          DataTextField="mothertongue"
          DataValueField="mothertongue">
  <asp:ListItem Value="0" Text="-Select-"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
   ConnectionString="<%$ ConnectionStrings:NewMatrimonyConnectionString %>"
   SelectCommand="SELECT distinct  [mothertongue] FROM [tbl_mothertongue]union all select 'Others'"></asp:SqlDataSource>
   <asp:TextBox ID="txtmothertongue" runat="server" 
       Visible="False" AutoPostBack="True"></asp:TextBox>
<asp:TextBox ID="txtmothertongue" runat="server" Visible="False"
       AutoPostBack="True"></asp:TextBox>

因为你没有提供太多的数据,我可以用我的数据给你一个解决方案

 if (ddl.items.Contains(value)) 
 {
       //show message it already contains item
 }

那么你这里有什么问题?请更具体一点!!你的问题含糊不清,不完整。很难说这里有什么问题。出于这个原因,我投票决定关闭它。请在这个主题中提出一个真正的问题。那么你想在客户端还是服务器端使用它?