I wish to ask that how do I compare 2 drop down list value so that they can't be same. <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem Text="Kuala Lumpur International Airport" Value="KUL"></asp:ListItem> <asp:ListItem Text="Kota Kinabalu International Airport" Value="BKI"></asp:ListItem> <asp:ListItem Text="Penang International Airport" Value="PEN"></asp:ListItem> </asp:DropDownList>
`<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem Text="Kuala Lumpur International Airport" Value="KUL"></asp:ListItem>
<asp:ListItem Text="Kota Kinabalu International Airport" Value="BKI"></asp:ListItem>
<asp:ListItem Text="Penang International Airport" Value="PEN"></asp:ListItem> </asp:DropDownList>`
How do I do that so that 2 values won't be the same. Like when user select Kuala Lumpur International Airport in DropDownList1 they can't select Kuala Lumpur International Airport in DropDownList2. Thanks for everyone that help. :)
You can use CompareValidator
<asp:CompareValidator ID="Validator"
runat="server"
ControlToValidate="DropDownList1"
ControlToCompare="DropDownList2"
ErrorMessage="Please select a different airport."
Type="String"
Operator="NotEqual"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.