Sorry if I couldn't explain my problem very clearly. Let me try one more time.
If we wrote the code like that,
HTML View
<asp:GridView ID="GridView1" runat="server" >
</asp:GridView>
Code-behinded File
protected void Page_Load(object sender, EventArgs e)
{
List<string> list = new List<string>();
list.Add("Alien");
GridView1.DataSource = list;
GridView1.DataBind();
}
the HTML tag will be generated as fellows by default ~
<table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">
<tr>
<td>Alien</td>
</tr><tr>
</table>
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.
Best Regards,
Michael Sync
The more you share, the more you get..
http://michaelsync.net