Bind Gridview in ASP.Net C#

Bind Gridview fron Database in ASP.Net C#


Gridview control is the one of the main control of ASP.Net.

Gridview control is used to display data from Database to user webform in specific format.

STEP – 1 First Bind data to gridview we have to make connection between Database and our ASP.Net website.

learn for connectivity visit – connectivity with Database with ASP.Net


STEP – 2 After making Connection take Gridview control on webform.

<form id=”form1″ runat=”server”>
<table style=”z-index: 100; left: 312px; position: absolute; top: 120px”>
<td style=”width: 100px”>
<asp:GridView ID=”GridView1″ runat=”server” BackColor=”White” BorderColor=”#CC9966″ BorderStyle=”None” BorderWidth=”1px” CellPadding=”4″>
<RowStyle BackColor=”White” ForeColor=”#330099″ />
<FooterStyle BackColor=”#FFFFCC” ForeColor=”#330099″ />
<PagerStyle BackColor=”#FFFFCC” ForeColor=”#330099″ HorizontalAlign=”Center” />
<SelectedRowStyle BackColor=”#FFCC66″ Font-Bold=”True” ForeColor=”#663399″ />
<HeaderStyle BackColor=”#990000″ Font-Bold=”True” ForeColor=”#FFFFCC” />



Gridview in
Gridview in


STEP – 3 Now write the below code on page load

public partial class _Default : System.Web.UI.Page
// Declare DataTable and TableAdapter Object here..
User_DSTableAdapters.USERMST_SELECTTableAdapter UserAdapter = new User_DSTableAdapters.USERMST_SELECTTableAdapter();

protected void Page_Load(object sender, EventArgs e)
if (Page.IsPostBack == false)
USerDT = UserAdapter.Select();

GridView1.DataSource = USerDT;




(Visited 23 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha *