0% found this document useful (0 votes)
89 views

C# Grid View From SQL Server DatabAse

1. The document provides steps to display data in a GridView control in ASP.NET, including designing a database table, adding a class to handle data access, binding the GridView to a data source, and displaying the output. 2. Key steps are designing a database table, adding a DAL class to retrieve data, dropping a GridView on an ASPX page, binding the GridView to a data source in the code-behind, and running the application. 3. The GridView is then populated with data from the database table when the application is run.

Uploaded by

Zohair Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views

C# Grid View From SQL Server DatabAse

1. The document provides steps to display data in a GridView control in ASP.NET, including designing a database table, adding a class to handle data access, binding the GridView to a data source, and displaying the output. 2. Key steps are designing a database table, adding a DAL class to retrieve data, dropping a GridView on an ASPX page, binding the GridView to a data source in the code-behind, and running the application. 3. The GridView is then populated with data from the database table when the application is run.

Uploaded by

Zohair Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

How to show data in GridView

Steps are:

1. Design a Database, named ICS


a. Design a table tblITemClass (ItemClassSID, ItemClass, ItemclassDescription)
b. Add some data to the table

2. Design a new Website


a. Add a class as shown here:

Click Add New Item, you will see the screen

[Type text]
Select Class, and rename it as DAL.CS

Next, Press Add Button

You will see the message as shown

Press Yes button

This will add a new class named DAL.CS under app_code folder as shown here

[Type text]
Add the following line of code as highlighted in the figure below

Next, declare a variable of type string as shown in the highlighted line below

Now, add the text as shown in the highlighted line below

[Type text]
Add the method as shown in the figure in the indicated space

Now, open the default.aspx page as shown

[Type text]
Drop and drag the GridView from the tool box in between <div> tag as shown

[Type text]
Now, open the default.aspx.cs file from the solution explorer

Choose the Open option

You will see the code as shown

[Type text]
Now add the line as shown in the highlighted line

Add the following code as shown in the highlighted line below

[Type text]
Now, run the application and see the output

Written By:
Saif ur Rehman
Assistant Professor, UIIT
PMAS Arid Agriculture University, Rawalpindi

[Type text]

You might also like