i have a gridview inside a repeater, and a dropdownlist insid the gridview. now i want no user can select one value twice.my code is
<asp:Repeater ID="rep_test" runat="server">
<ItemTemplate>
<asp:GridView ID="grd_test" runat="server" Style="text-align: center;
width: 375px;" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="hello" DataField="hello" />
</Columns>
<Columns>
<asp:BoundField HeaderText="item" DataField="item" />
</Columns>
<Columns>
<asp:TemplateField HeaderText="Assign to">
<ItemTemplate>
<asp:DropDownList ID="drp_Assign" runat="server">
<asp:ListItem Value="1"> 1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:DropDownList ID="drp_Address" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:Repeater>
i want to detect the duplicate value for drodown “drp_Assign”.
please see the image the values in comp number should not be duplicate if a user selected “1” for one row then he will not be able to selected same value in second row . if he tries to do then alert message will be shown that you have selected this value already choose another.”
I am using the repeater as the container,
#rep_test, and matching all dropdowns inside the container so that user can’t select same values.NOTE : Double check your Repeater ID in your browser as .Net will change it.
UNLESS you change your Client ID Mode to static [.Net 4.0], e.g. :
REF : http://weblogs.asp.net/asptest/archive/2009/01/06/asp-net-4-0-clientid-overview.aspx
JQuery:
WORKING EXAMPLE : http://jsfiddle.net/zrcZM/2