[英]Validate 2 Drop-Down List
I wish to ask that how do I compare 2 drop down list value so that they can't be same. 我想问一下如何比较2个下拉列表的值,以使它们不能相同。 <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. 我该怎么做,以便2个值不会相同。 Like when user select Kuala Lumpur International Airport in DropDownList1 they can't select Kuala Lumpur International Airport in DropDownList2. 就像用户在DropDownList1中选择吉隆坡国际机场时一样,他们无法在DropDownList2中选择吉隆坡国际机场。 Thanks for everyone that help. 谢谢大家的帮助。 :) :)
You can use CompareValidator 您可以使用CompareValidator
<asp:CompareValidator ID="Validator"
runat="server"
ControlToValidate="DropDownList1"
ControlToCompare="DropDownList2"
ErrorMessage="Please select a different airport."
Type="String"
Operator="NotEqual"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.