Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在选择下拉项时打开复选框列表。?_C#_Asp.net - Fatal编程技术网

C# 如何在选择下拉项时打开复选框列表。?

C# 如何在选择下拉项时打开复选框列表。?,c#,asp.net,C#,Asp.net,在我的应用程序中,我有一个文本框、下拉列表和复选框列表。现在,我希望在选择下拉项时显示复选框列表。复选框列表中的列表将取决于我从dropdownlist中选择的项目。您可以使用dropdownlist selected index changed事件进行选择更改。复选框可见 代码隐藏: Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Han

在我的应用程序中,我有一个文本框、下拉列表和复选框列表。现在,我希望在选择下拉项时显示复选框列表。复选框列表中的列表将取决于我从dropdownlist中选择的项目。

您可以使用dropdownlist selected index changed事件进行选择更改。复选框可见

代码隐藏:

 Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        If DropDownList1.SelectedIndex > 1 Then
            CheckBoxList1.Visible = True
            If DropDownList1.SelectedIndex = 2 Then
                'Put Your Code Here
            Else
                'Put Your Code Here
            End If
        Else
            CheckBoxList1.Visible = False
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        CheckBoxList1.Visible = False
    End Sub
设计:

<asp:DropDownList ID="DropDownList1" runat="server" Height="48px" Width="256px" AutoPostBack="true"OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >


您可以通过设置checkboxlist的Visible属性来隐藏/显示checkboxlist。在DropDownList标记中,添加OnSelectedIndexChanged=“DropDownList 1\u SelectedIndexChanged”以便向控件注册事件处理程序。请阅读以下内容:因为您似乎还没有发现如何接受答案。