This tutorial is about how to retrieve data from the database and display in the GridView using SqlDataSource in ASP.NET. It is very simple with the SqlDataSource.
Here is steps.
Step 1:
On the page add the GridView control. after that select the GridView and click on the top right side button a GridView Tasks window will appear now from this window choose the new data source from the DropDownList. Like this:
|
Select new data source |
Step 2:
when you select new data source from the DropDownList a new window will appear where you choose the database type. From this window choose the database type and click on OK button. Like this:
|
Choose database type |
Step 3:
Now a wizard will start for configure data source. From the "choose your data connection" window select the a data connection from the DropDownList and press next button.
|
Data Connection |
Step 4:
Now connection string window will appear, on this window write the connection string name in the textbox and click on next.
|
Connection string |
Step 5:
After connection string a "configure the select statement" window will appear. On this window first select the table from the DropDownList and then select the columns that you want to display in the GridView and press next.
|
Select statement |
Step 6:
Now test query window will appear. to preview the data returned by this data source, click Test Query. to complete this wizard click Finish.
|
Test Query |
Last Step 7:
Now run the project and check the page data will show in the GridView like this:
|
Data show in GridView |
No comments:
Post a Comment