Thursday, 27 February 2014

What is gridview control in ASP.NET? What are the Templates and main Events in GridView.

In this article I will explain what is gridview control in ASP.NET? What are the Templates and main Events in GridView.

GridView:

The GridView control is a feature rich and versatile control used to accept, display, and edit data on a web page. It is a commonly used control in ASP.Net web applications. 

To use a GridView control a DataSource control has to be attached to the GridView control. The property DataSourceID of the GridView control binds the GridView control to the DataSource control and allows paging, sorting and database operations with the DataSource. 

There are four popular DataSource controls and SqlDataSource control is one of them. We use SqlDataSource control, to attach the GridView control to the Sql Server Data base. 

The SqlDataSource control contains ConnectionString, SelectCommand, UpdateCommand and DeleteCommand properties. The ConnectionString property connects the DataSource (SqlDataSource) control to the database and properties such as SelectCommand, InsertCommand, UpdateCommand, DeleteCommand contains SQL statements that are executed when we display, insert and delete records using the GridView control. 

Types of Templates:

1.      Header Template.
2.      Item Template.
3.      Edit Item Template.
4.      Footer Template.
5.      Empty Data Template.

Main Grid View Events:

1.      PageIndexChanging
2.      RowCancelingEdit
3.      RowCommand
4.      RowDataBound
5.      RowDeleting
6.      RowEditing

7.      RowUpdating

No comments:

Post a Comment