ASP.NET Data Grid Control using Stored Procedure
In this demo, I will be using VS.NET (Visual Studio.NET) and SQL Server as my Database.
First we need to add the following controls on the form.
1. Drag and Drop A Data Grid Control and a Label Control on to the form.
2. Then we can Auto Format our Data Grid.
3. The final design should look like in Figure
1. Next we need to connect to our database using a SQLData Adapter.
2. The wizard starts as shown in Figure
3. Click Next and Proceed.
? Next choose your Database Connection
We next need to decide whether we need SQL statements or use existing stored procedures.
Since we are calling stored procedures, we should choose option 3.
Choose the stored procedure you want to use. For this Demo , I have stuck to the Ten Most Expensive Products Stored Procedure.
In our Final screen click finish.
In our next section we need to generate our Dataset, in order to bind our DataGrid.
In our next screen we see how to name our DataSet.
Next we Bind our DataSet with our DataGrid as shown in the next screen
In the next screen , we should see the final look , before, we start coding our WebApp.
In the last part of this tutorial is the code. Type this in the Page Load Event.
SqlDataAdapter1.Fill(DsStoredProc1)
Me.DataBind()
DataGrid1.DataBind()
[Please note: If you are trying to access a remote server, please provide both username and password, for the application to work smooth. And for those of you who are still not sure, whether your System.Data and System.Data.SqlClient namespaces are not loaded, please check before doing any of the above]
First we need to add the following controls on the form.
1. Drag and Drop A Data Grid Control and a Label Control on to the form.
2. Then we can Auto Format our Data Grid.
3. The final design should look like in Figure
1. Next we need to connect to our database using a SQLData Adapter.
2. The wizard starts as shown in Figure
3. Click Next and Proceed.
? Next choose your Database Connection
We next need to decide whether we need SQL statements or use existing stored procedures.
Since we are calling stored procedures, we should choose option 3.
Choose the stored procedure you want to use. For this Demo , I have stuck to the Ten Most Expensive Products Stored Procedure.
In our Final screen click finish.
In our next section we need to generate our Dataset, in order to bind our DataGrid.
In our next screen we see how to name our DataSet.
Next we Bind our DataSet with our DataGrid as shown in the next screen
In the next screen , we should see the final look , before, we start coding our WebApp.
In the last part of this tutorial is the code. Type this in the Page Load Event.
SqlDataAdapter1.Fill(DsStoredProc1)
Me.DataBind()
DataGrid1.DataBind()
[Please note: If you are trying to access a remote server, please provide both username and password, for the application to work smooth. And for those of you who are still not sure, whether your System.Data and System.Data.SqlClient namespaces are not loaded, please check before doing any of the above]
Labels: DataGrid

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home