This article shows how to bind a dropdown list from the database and on selecting any record from this dropdown how to fill in respective records in a GridView.
I am writing this article because I got a request from one of my users and friends. He stuck in this business requirement and asked me to write something about this. So I will show this functionality in 2 ways. Here in this part I will show this using ASP.NET C# and SQL Server and in the next part I will show it using jQuery.Figure 1 shows my Data Table in design mode from which I will show this requirement.Figure 1Script of My Table
Figure 2 shows the data in the table.Figure 2.Here In this you can see I have employee records with Manager Id. So in DropDown I will see only Manager and on selecting a Manager from the DropDown I will show the team information in the GridView:The following is my aspx:
Now my aspx.cs code is:
The following is the the connection string in the Web.config file:
Figure 3Figures 4 - 9 show the resutls from executing the application.Figure 4Figure 5Figure 6Figure 7Figure 8Figure 9In the next article I will show this functionality using jQuery.
Diving Into ASP.NET WebAPI