Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Aug 18, 2007 05:38 PM|LINK
Sorry if I couldn't explain my problem very clearly. Let me try one more time.
If we wrote the code like that,
<asp:GridView ID="GridView1" runat="server" >
protected void Page_Load(object sender, EventArgs e)
List<string> list = new List<string>();
GridView1.DataSource = list;
the HTML tag will be generated as fellows by default ~
<table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">
I noticed that there is no thead or tbody or tfoot in the generated HTML table. I want GridView to generate the HTML table with those tags. So, I tried with the follwing code.
//This replaces <td> with <th> and adds the scope attribute
grid.UseAccessibleHeader = true;
//This will add the <thead> and <tbody> elements
grid.HeaderRow.TableSection = TableRowSection.TableHeader;
grid.HeaderRow.CssClass = "fixedHeader";
//This adds the <tfoot> element. Remove if you don't have a footer row
grid.FooterRow.TableSection = TableRowSection.TableFooter;
then, I can add thead, tbody and tfoot to generated HTML successfully. It allows me to set the custom CSS class by using HeaderRow.CssClass and FooterRow.CssClass properties. But I found no way to specify the custom CSS class for tbody. So, it would be
great if anyone tell me to achieve this goal.
Thanks in advance.