Saturday, November 23, 2013

GridView Accessible Header

/// 
    /// Adds THeadere TBody tag to gridview
    /// http://dotnetinside.com/en/framework/v4.0.30319/System.Web/TableRow
    /// 
    /// the gridview
public void MakeAccessible(GridView grid)
{
        if (grid == null || grid.Rows.Count <= 0) return;
        //This replaces  with  and adds the scope attribute
grid.UseAccessibleHeader = true;
//This will add the and elements
if (grid.HeaderRow != null) grid.HeaderRow.TableSection = TableRowSection.TableHeader;
if (grid.TopPagerRow != null) grid.TopPagerRow.TableSection = TableRowSection.TableHeader;
//This adds the element. Remove if you don't have a footer row
if (grid.BottomPagerRow != null) grid.BottomPagerRow.TableSection = TableRowSection.TableFooter;
}

No comments: