Asp.Net C# Grid view From Sql Server DatabAse

Post on 20-Jan-2016

14 views 0 download

description

How to show data in GridView

Transcript of 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

[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