Hello Forum,
How can I add List Item automatically from a data table to the Dropdown List and it should be based on the type of item?
I have a dropdown list on my web form but I don’t want to add the list items manually, but from a column in the database table.
For example, if I have a table and dropdown list like this
Id
|
States
|
City
|
Name_of_Estates
|
1
|
Kamala
|
Queens
|
County Estate
|
2
|
Delta
|
Moore
|
Eric Moore
|
3
|
Rivers
|
Ripper
|
Danny Estate
|
4
|
Rivers
|
Port Harcourt
|
Sun City Estate
|
5
|
Delta
|
Welling
|
G.R.A Estate
|
6
|
Kamala
|
Queens
|
Low Cost Housing Estate
|
7
|
Delta
|
Moore
|
Howson Wright
|
8
|
Delta
|
Moore
|
Yale housing
|
And in the table, is where a user will register by inserting the State, City and name of estate.
Entities – (DropdownList)
- Educational Institutions
- Estates
- Stores
When a user clicks on “Entities” then a list will appear, containing the 3 entities listed above. From there, the user will select one entity (example: Estates) after selecting the “Estates” entity and inputting other required data, it will be inserted into the a particular table based on the selected entity – “Estate” because I will have 3 data tables to inserted data based on the entities (e.g EduTable will be based on Educational Institutions, EstateTable = Estates and StoreTable = Stores table).
Finally, if another user logs in and navigates to another web page where there are 3 dropdownLists; and selects in the dropdown lists according to State and City then the Name of Estates should be listed as List Items in the third dropdown list which will be gotten from the “Name_of_Estates” column in the table.
STATES:
Kamala
Delta (user selects Delta)
Rivers
CITY:
Queens
Moore (user selects Moore)
Ripper
Name of Estates:
If the user selects Delta and Moore, then the 3rd dropdown list Items should contain the names of Estates under Delta (State) and Moore (City), which will be gotten from database table.
Please I want to know how to do this, and I will really appreciate your help. Thank you.
Here is my HTML
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="Medium" Text="States"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Width="10%" Height="20px" AutoPostBack="true">
<asp:ListItem Text="Select State" />
<asp:ListItem Text="Kamala" Value="Kamala" />
<asp:ListItem Text="Delta" Value="Delta" />
<asp:ListItem Text="Rivers" Value="Rivers" />
</asp:DropDownList>
<br />
<br />
<asp:Label ID="Label2" runat="server" Font-Bold="true" Font-Size="Medium" Text="City"></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" Width="10%" Height="20px" AutoPostBack="true">
<asp:ListItem Text="Select City" />
<asp:ListItem Text="Queens" Value="Queens" />
<asp:ListItem Text="Moore" Value="Moore" />
<asp:ListItem Text="Rippers" Value="Rivers" />
<asp:ListItem Text="Port Harcourt" Value="Port Harcourt" />
<asp:ListItem Text="Welling" Value="Welling" />
</asp:DropDownList>
<br />
<br />
<asp:Label ID="Label3" runat="server" Font-Bold="true" Font-Size="Medium" Text="Estates"></asp:Label>
<asp:DropDownList ID="DropDownList3" runat="server" Width="10%" Height="20px" AutoPostBack="true">
</asp:DropDownList>
</div>
</form>