Garima Bansal

Garima Bansal

  • 1.1k
  • 675
  • 39.2k

cascade a dropdown from database in asp.net

Mar 9 2023 5:45 AM

I have two databse table 

1: Sector 

2: Project

In Sector table there is 4 sectors(sector1,sector2,sector3,sector4)

and if sector1 is selected then then related project shown 

<div class="row mb-3">
    <label for="inputText" class="col-sm-4 col-form-label">Sector :: </label>
    <div class="col-sm-8">
        <asp:DropDownList ID="ddlsector" CssClass="form-select" runat="server">
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Select Sector" ControlToValidate="ddlsector" ForeColor="Red"></asp:RequiredFieldValidator>
    </div>
</div>

<div class="row mb-3">
    <label for="inputText" class="col-sm-4 col-form-label">Project :: </label>
    <div class="col-sm-8">
        <asp:DropDownList ID="ddlproject" CssClass="form-select" runat="server">
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Select Project" ControlToValidate="ddlproject" ForeColor="Red"></asp:RequiredFieldValidator>
    </div>
</div>

 


Answers (6)