在C#.net中验证动态组合框 [英] Validate Dynamic Combobox in C#.net

查看:65
本文介绍了在C#.net中验证动态组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,
我知道要创建一个动态属性.但是我不知道如何验证该属性.例如,我以自己的形式(它的动态属性)创建了一个五个组合框
在该组合框中,某些项位于组合框中.例如:DELL,IBM,HP,LG,SAMSUNG.如果我在第一个组合框中选择了一个DELL,而又不在另一个四组合框中选择了DELL.如何解决此问题?请告诉我.
谢谢
问候
Lakshmi Narayanan.S

Hi friends,
I know to create a Dynamic Properties . But I don''t know how to validate that property . For example i created a Five Combobox in my form(It''s dynamic Property)
In that Combobox,some items are in the Combobox. For example:DELL,IBM,HP,LG,SAMSUNG.If i select a DELL in the First Combobox and i will not select a DELL in another Four Combobox.How can i fix this problem?please tell me.
Thanks
Regards
Lakshmi Narayanan.S

推荐答案

将所选项目/值与其他列表进行比较&删除它.

Compare the selected items/values with other list & remove it.

<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True" xmlns:asp="#unknown">
                OnSelectedIndexChanged="Selection_Change1">
    <asp:listitem value="1">DELL</asp:listitem>
    <asp:listitem value="2">IBM</asp:listitem>
    <asp:listitem value="3">HP</asp:listitem>
    <asp:listitem value="4">LG</asp:listitem>
    <asp:listitem value="5">SAMSUNG</asp:listitem>
</asp:dropdownlist>
<asp:dropdownlist id="DropDownList2" runat="server" autopostback="True" xmlns:asp="#unknown">
                OnSelectedIndexChanged="Selection_Change2">
    <asp:listitem value="1">DELL</asp:listitem>
    <asp:listitem value="2">IBM</asp:listitem>
    <asp:listitem value="3">HP</asp:listitem>
    <asp:listitem value="4">LG</asp:listitem>
    <asp:listitem value="5">SAMSUNG</asp:listitem>
</asp:dropdownlist>


void Selection_Change1(Object sender, EventArgs e)
      {
          DropDownList2.Items.Remove(DropDownList2.SelectedValue);  
      }
void Selection_Change2(Object sender, EventArgs e)
      {
          DropDownList1.Items.Remove(DropDownList1.SelectedValue);  
      }



我只是给您示例示例,请根据您的需要进行更改.还可以处理异常.



I just gave you sample idea, do changes based on your need. Also handle exceptions.


这篇关于在C#.net中验证动态组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆