Gridview insert update delete in asp.net

Asp .net gridivew is very useful and advanced data bound control in asp .net. Gridiview is used to display data in tabular format. The main features of asp .net gridview control are select, sort, edit and delete items.

You can bind gridivew with different types of data sources like lists, arrays, sql server, sql datasource entity data source etc. This gives you a great power when you want to display data in your asp .net website. There is inbuilt support available for sorting the columns, edit a row and delete a row. For more info read: gridview insert update delete in asp.net.

For designing of gridview there are lots of predefined templates available however you can also design gridiview with custom CSS. Designing of gridview is really easy as gridview is rendered as HTML Table and you can apply any CSS classes you can apply to CSS table.

My favorite feature in gridview is sorting and paging, you can easily add sorting and paging feature in asp .net gridview without writing single line of code. To turn on paging and sorting in gridiview you only needs to set "Allow paging" and "Allow sorting" to true.

Binding data: While binding data into gridview control by default the "AutoGenerateColumns" property is set to true this means gridview will automatically create columns based on the columns present in the provided datasource. However if you wish to add your custom columns or neglect some columns from datasource to be displayed in gridview you can set "AutogenertateColumns" to false and define your custom columns. Click here to learn more about gridview insert update delete in asp.net.

There are multiple column fields available to customize gridview:

1.	Boundfield: This field is used to display data present in datasource field. 2.	Buttonfield: This is used to insert custom buttons inside your gridview control. 3.	CheckboxField: This is used to display checkbox inside gridview column. 4.	CommandField: This is used to display predefined command buttons like select, edit. 5.	HyperLinkField: This is used to display hyperlinks within gridview control. 6.	ImageField: This is used to display images within gridview control. 7.	TemplateField: This is used to create custom column field.

There are different style properties available for those who are not good in writing CSS. You can use these properties to easily style asp .net gridview some of the available CSS properties are:

•	AlternatingRowStyle: This is used to style every alternate row in the gridview. By using this you can apply custom font color, background color etc. to every alternative row of gridview control. •	FooterStyle: This is used to apply styles to footer of the gridview control. •	HeaderStyle: You can use header style property to design header of gridview control. •	PagerStyle: Used to apply design to pager. •	SelectedRowStyle: You can also customize layout of selected row by using this property.

Gridview also provides several events you can use to do custom programming. Some of the main events of gridview control are:

•	RowDataBound: You can use this event to modify contents of a row before gridview is rendered to page. This event occurs when a row is bound to data. This is mainly used when you want to do some calculations on row data. •	RowCommand: This event is used to do write custom code when a button is clicked inside a gridview control. •	RowDeleted: This event occurs when is row is deleted from gridview control. You can use this event to check status of row deletion. •	SelectedIndexChanged: You can use this event to do custom logic when row's select button is clicked. •	Sorting: This event happens when hyperlink of a sort column is clicked you can use this event to add your custom logic with sorting.

You can see how powerful and customizable asp .net gridivew control is. You can easily perfrom Gridview crud operation in asp .net c#, sorting, deleting, paging, designing using asp .net gridview control.