A Look at the GridView's New Sorting Styles in ASP.NET 4.0

Posted on Internet.com See other posts from Internet.com
Published on Wed, 03 Feb 2010 05:00:00 +010 Indexed on 2010/03/07 23:13 UTC
Read the original article Hit count: 916

Filed under:
Scott Mitchell looks at four new sorting-related style properties added to the GridView in ASP.NET 4.0.

© Internet.com or respective owner

A Look at the GridView's New Sorting Styles in ASP.NET 4.0

Posted on 4 Guys From Rolla See other posts from 4 Guys From Rolla
Published on Wed, 03 Feb 2010 00:00:00 GMT Indexed on 2010/03/07 23:27 UTC
Read the original article Hit count: 916

Filed under:

Like every Web control in the ASP.NET toolbox, the GridView includes a variety of style-related properties, including CssClass, Font, ForeColor, BackColor, Width, Height, and so on. The GridView also includes style properties that apply to certain classes of rows in the grid, such as RowStyle, AlternatingRowStyle, HeaderStyle, and PagerStyle. Each of these meta-style properties offer the standard style properties (CssClass, Font, etc.) as subproperties.

In ASP.NET 4.0, Microsoft added four new style properties to the GridView control: SortedAscendingHeaderStyle, SortedAscendingCellStyle, SortedDescendingHeaderStyle, and SortedDescendingCellStyle. These four properties are meta-style properties like RowStyle and HeaderStyle, but apply to column of cells rather than a row. These properties only apply when the GridView is sorted - if the grid's data is sorted in ascending order then the SortedAscendingHeaderStyle and SortedAscendingCellStyle properties define the styles for the column the data is sorted by. The SortedDescendingHeaderStyle and SortedDescendingCellStyle properties apply to the sorted column when the results are sorted in descending order.

These four new properties make it easier to customize the appearance of the column by which the data is sorted. Using these properties along with a touch of Cascading Style Sheets (CSS) it is possible to add up and down arrows to the sorted column's header to indicate whether the data is sorted in ascending or descending order. Likewise, these properties can be used to shade the sorted column or make its text bold. This article shows how to use these four new properties to style the sorted column. Read on to learn more!
Read More >

© 4 Guys From Rolla or respective owner