Making a GridView render the header in the thead tag
By default a ASP.Net GridView control renders everything inside a <tbody> tag, which isn't good when doing Bootstrap tables. Adding the following will force it to render inside the <thead> and <tfoot> tags.
myGridView.DataBound +=
(source, args) =>
{
var gridView = (GridView)source;
if (gridView.HeaderRow != null)
{
gridView.HeaderRow.TableSection = TableRowSection.TableHeader;
}
if (gridView.FooterRow != null && gridView.ShowFooter)
{
gridView.FooterRow.TableSection = TableRowSection.TableFooter;
}
};
Source:
http://www.west-wind.com/weblog/posts/2010/Nov/18/Adding-proper-THEAD-sections-to-a-GridView
1 comments:
ASP.NET GridView is good in may terms as I have dealt with it many times being an ASP.NET Developer. But when it comes to Bootstrap tables and ASP.NET GridView both together, it has always created a problem to me.
Post a Comment