Saturday, November 23, 2013

GridView Accessible Header

  1. /// <summary>  
  2.     /// Adds THeadere TBody tag to gridview  
  3.     /// http://dotnetinside.com/en/framework/v4.0.30319/System.Web/TableRow  
  4.     /// </summary>  
  5.     /// <param name="grid">the gridview  
  6. public void MakeAccessible(GridView grid)  
  7. {  
  8.         if (grid == null || grid.Rows.Count <= 0) return;  
  9.         //This replaces  with  and adds the scope attribute  
  10.   
  11. grid.UseAccessibleHeader = true;  
  12.   
  13. //This will add the  and  elements  
  14.   
  15. if (grid.HeaderRow != null) grid.HeaderRow.TableSection = TableRowSection.TableHeader;  
  16.   
  17. if (grid.TopPagerRow != null) grid.TopPagerRow.TableSection = TableRowSection.TableHeader;  
  18.   
  19. //This adds the  element. Remove if you don't have a footer row  
  20.   
  21. if (grid.BottomPagerRow != null) grid.BottomPagerRow.TableSection = TableRowSection.TableFooter;  
  22.   
  23. }  

No comments: