Asp.Net C# Grid view From Sql Server DatabAse

8
[Type text] 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

description

How to show data in GridView

Transcript of Asp.Net C# Grid view From Sql Server DatabAse

Page 1: Asp.Net C# Grid view From Sql Server DatabAse

[Type text]

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

Page 2: Asp.Net C# Grid view From Sql Server DatabAse

[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

Page 3: Asp.Net C# Grid view From Sql Server DatabAse

[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

Page 4: Asp.Net C# Grid view From Sql Server DatabAse

[Type text]

Add the method as shown in the figure in the indicated space

Now, open the default.aspx page as shown

Page 5: Asp.Net C# Grid view From Sql Server DatabAse

[Type text]

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

Page 6: Asp.Net C# Grid view From Sql Server DatabAse

[Type text]

Now, open the default.aspx.cs file from the solution explorer

Choose the Open option

You will see the code as shown

Page 7: Asp.Net C# Grid view From Sql Server DatabAse

[Type text]

Now add the line as shown in the highlighted line

Add the following code as shown in the highlighted line below

Page 8: Asp.Net C# Grid view From Sql Server DatabAse

[Type text]

Now, run the application and see the output

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