Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 08, 2013 03:12 AM by Sujeet Saste
Member
21 Points
84 Posts
Jan 08, 2013 02:47 AM|LINK
Hi:
I have a problem about setting css class in gridview, the following is the examples codes:
<asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False" BorderColor="#0033CC" BorderStyle="Solid" CaptionAlign="Top" AllowPaging="True" PageSize="10" > <PagerSettings Position="Top" Mode="NumericFirstLast" FirstPageText="First" LastPageText="Finally" /> <EmptyDataRowStyle BackColor="#339966" BorderStyle="Solid" /> <Columns> <asp:BoundField DataField="caseid" HeaderText="Case" /> <asp:BoundField DataField="casename" HeaderText="Name" /> </Columns> </asp:GridView>
The header will included by <th></th> and its data will be enclosed with<td></td>;
And the problem is how to set these elements two individual css class, that means the <th class="test1"></th>
and <td class="test2"></td>. Is it possible to do that. Thanks a lot.
Contributor
3832 Points
651 Posts
Jan 08, 2013 02:52 AM|LINK
Please refer
http://stackoverflow.com/questions/3921497/setting-gridview-header-color
2998 Points
572 Posts
Jan 08, 2013 03:12 AM|LINK
You can achieve it by 2 ways :
By using your both css classes for th and td, like :
<asp:GridView ID="GridView1" runat="server"> <HeaderStyle CssClass="test1" /> <RowStyle CssClass="test2" /> <AlternatingRowStyle CssClass="test2" /> </asp:GridView>
Or by creating one class, which includes styles for th and td and apply it to gridview directly :
<asp:GridView ID="GridView1" runat="server" CssClass="MyGrid"> <!-- MyGrid class is the combination of test1 and test2 classes --> </asp:GridView>
If have any query feel free to ask..
abramhum.c.l
Member
21 Points
84 Posts
CSS in gridview
Jan 08, 2013 02:47 AM|LINK
Hi:
I have a problem about setting css class in gridview, the following is the examples codes:
<asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False" BorderColor="#0033CC" BorderStyle="Solid" CaptionAlign="Top" AllowPaging="True" PageSize="10" > <PagerSettings Position="Top" Mode="NumericFirstLast" FirstPageText="First" LastPageText="Finally" /> <EmptyDataRowStyle BackColor="#339966" BorderStyle="Solid" /> <Columns> <asp:BoundField DataField="caseid" HeaderText="Case" /> <asp:BoundField DataField="casename" HeaderText="Name" /> </Columns> </asp:GridView>The header will included by <th></th> and its data will be enclosed with<td></td>;
And the problem is how to set these elements two individual css class, that means the <th class="test1"></th>
and <td class="test2"></td>. Is it possible to do that. Thanks a lot.
senthilwaits
Contributor
3832 Points
651 Posts
Re: CSS in gridview
Jan 08, 2013 02:52 AM|LINK
Please refer
http://stackoverflow.com/questions/3921497/setting-gridview-header-color
Senthil Kumar Sundaram
Sujeet Saste
Contributor
2998 Points
572 Posts
Re: CSS in gridview
Jan 08, 2013 03:12 AM|LINK
You can achieve it by 2 ways :
By using your both css classes for th and td, like :
<asp:GridView ID="GridView1" runat="server"> <HeaderStyle CssClass="test1" /> <RowStyle CssClass="test2" /> <AlternatingRowStyle CssClass="test2" /> </asp:GridView>Or by creating one class, which includes styles for th and td and apply it to gridview directly :
<asp:GridView ID="GridView1" runat="server" CssClass="MyGrid"> <!-- MyGrid class is the combination of test1 and test2 classes --> </asp:GridView>If have any query feel free to ask..
Do FEAR (Face Everything And Rise)
Please mark as Answer if my post helps you..!
My Blog