Hide Show ASP.Net DataList based on CheckBox Checked (Selected) using C# and VB.Net

Last Reply 10 months ago By pandeyism

Posted 10 months ago

In below code intially all data list will be visible and when i check on first check box other will be invisible and only datalist one be visible, if i check on one and two check box only two datalist should be visible and so on and when i uncheck it it will show all datalist.

so please help me

<div>
    <div class="dropdown">
        <button class="dropbtn">Dropdown</button>
        <div class="dropdown-content">
        <a href="#">
            <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"  />Nozzle</a>
        <a href="#">
            <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="true"   />Lateral</a>
        <a href="#">
            <asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="true"   />Submain Pipe</a>
        <a href="#">
            <asp:CheckBox ID="CheckBox4" runat="server" AutoPostBack="true"   />Main Pipe</a>
        <a href="#">
            <asp:CheckBox ID="CheckBox5" runat="server" AutoPostBack="true"  />Motor Pump</a>
    </div>
    </div>
    <hr />
    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" BorderStyle="Double">
        <ItemTemplate>
            nozzle_lph:
            <asp:Label ID="nozzle_lphLabel" runat="server" Text='<%# Eval("nozzle_lph") %>'></asp:Label>
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:Mycon %>' SelectCommand="SELECT [nozzle_lph] FROM [company_sprinkler_data]"></asp:SqlDataSource>
    <asp:DataList ID="DataList2" runat="server" DataSourceID="SqlDataSource2" BorderStyle="Double">
        <ItemTemplate>
            lateral_mm:
            <asp:Label ID="lateral_mmLabel" runat="server" Text='<%# Eval("lateral_mm") %>'></asp:Label>
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource runat="server" ID="SqlDataSource2" ConnectionString='<%$ ConnectionStrings:Mycon %>' SelectCommand="SELECT [lateral_mm] FROM [company_sprinkler_data]"></asp:SqlDataSource>
    <asp:DataList ID="DataList3" runat="server" DataSourceID="SqlDataSource3" BorderStyle="Double">
        <ItemTemplate>
            main_mm:
            <asp:Label ID="main_mmLabel" runat="server" Text='<%# Eval("main_mm") %>'></asp:Label>
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource runat="server" ID="SqlDataSource3" ConnectionString='<%$ ConnectionStrings:Mycon %>' SelectCommand="SELECT [main_mm] FROM [company_sprinkler_data]"></asp:SqlDataSource>
    <asp:DataList ID="DataList4" runat="server" DataSourceID="SqlDataSource4" BorderStyle="Double">
        <ItemTemplate>
            submain_mm:
            <asp:Label ID="submain_mmLabel" runat="server" Text='<%# Eval("submain_mm") %>'></asp:Label>
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource runat="server" ID="SqlDataSource4" ConnectionString='<%$ ConnectionStrings:Mycon %>' SelectCommand="SELECT [submain_mm] FROM [company_sprinkler_data]"></asp:SqlDataSource>
    <asp:DataList ID="DataList5" runat="server" DataSourceID="SqlDataSource5" BorderStyle="Double">
        <ItemTemplate>
            Sp_mpump_hp:
            <asp:Label ID="Sp_mpump_hpLabel" runat="server" Text='<%# Eval("Sp_mpump_hp") %>'></asp:Label>
            <br />
            <br />
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource runat="server" ID="SqlDataSource5" ConnectionString='<%$ ConnectionStrings:Mycon %>' SelectCommand="SELECT [Sp_mpump_hp] FROM [company_sprinkler_data]"></asp:SqlDataSource>
</div>

 

This question does not have replies that have been liked.