5 Very Useful Tips on ASP.NET GridView

By | January 14, 2014

ASP.NET GridView control is one of the most frequently used data binding control.  This control has several features and  you can use them to achieve most of your basic data grid related requirements without even write a single line of of code. However, there are some scenarios where the requirement may be some tricky and can not be done in a straight forward way . For an example customize the message in a row cell when there is a NULL value. So, for such requirements, you may need do some customization or overriding the actual functionalities by writing few blocks of additional code. Here is the list of 5 tips that can be very useful for you during your development. You can also apply this learning to solve other similar problems.

    1. How to change GridView column alignments for dynamic data source ?

GridView property ,ItemStyle-HorizontalAlign having few set of values, using  which we can change the alignments for dynamic data source. How to change GridView column alignments for dynamic data source ?

2. How to pass multiple values using GridView HyperLinkField ?

To implement this feature you need to know about DataNavigationUrlField and DataNavigateUrlFormatString properties of HyperLinkField.How to pass multiple values using GridView HyperLinkField ?

3. Displaying Custom Messages / Images with NULL Value in ASP.NET GridView

GridView control has a property, NullDisplayText. If we set NullDisplayText=”No Data” for every field for the data bound field which having NULL value will be replace by “No Data” No Data Displaying for NULL Value

4. Display custom messages or images when there is no records in GridView Data Source

You can use EmptyDataTemplate using GridView to display any custom message or Images or even web controls to add new records or whatever you want as per your requirements.Display custom messages or images when there is no records in GridView Data Source

5. How to Display “Yes” or “No” Instead of Checkbox while binding Boolean value with GridView ?

Sometime we may required to display either Yes/ No or “1/0” instead of Checked/ Unchecked Text Box.   This described how you can override the checkbox to your required  value in  GridView RowDataBound events. How to Display “Yes” or “No” Instead of Checkbox while binding Boolean value with GridView ?

Hope you have enjoyed all of them. Do share and let me know your view.

One thought on “5 Very Useful Tips on ASP.NET GridView

  1. Pingback: 3 Powerful Customization Tips for ASP.NET Calendar Control

Comments are closed.