i hava ddl and textbox..if my text box value already exist in ddl means i should display message as already exist in ddl..
i tried compare calidator..but not working,,,
<asp:DropDownList ID="ddlmothertongue" AppendD开发者_Python百科ataBoundItems="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>
Since you are not really supplying much data, I can just give you a solution with the data I have.
if (ddl.items.Contains(value))
{
//show message it already contains item
}
精彩评论