DatagGrid Cascade Style Sheet CSS

A

ABHIJIT B

Hi,

I want to use CSS StyleSheet for datagrid in my web page.
The code is given below,

ASPX code:

<asp:datagrid id="grdReport" runat="server" Width="720px"
BackColor="White"
AutoGenerateColumns="False"
CellPadding="4" Height="22px" BorderWidth="1px" BorderStyle="None"
BorderColor="#CC9966" PageSize="5">
<SelectedItemStyle
BackColor="InactiveCaptionText" ForeColor="Black" />
<Columns>
<asp:TemplateColumn
HeaderText="Select">
<ItemTemplate>
<asp:RadioButton
id="rdbSelect" runat="server" AutoPostBack="True"
OnCheckedChanged="SelectOnlyOne"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn
DataField="LoginName" SortExpression="LoginName"
HeaderText="LoginName"></asp:BoundColumn>
<asp:BoundColumn
DataField="FirstName" SortExpression="FirstName"
HeaderText="FirstName"></asp:BoundColumn>
<asp:BoundColumn
DataField="LastName" SortExpression="LastName" HeaderText="LastName"></
asp:BoundColumn>
</Columns>
<ItemStyle BorderColor="Black"
ForeColor="Black" />
<HeaderStyle BorderColor="Black"
ForeColor="Black" />
</asp:datagrid>
-----------------------------------------------------
I used CSS for GridView as given below,

<asp:GridView ID="gvSearchUsersList" runat="server" TabIndex="5"
PageSize="5" AllowPaging="True" AutoGenerateColumns="False"
OnPageIndexChanging="gvSearchUsersList_PageIndexChanging"
AllowSorting="True" GridLines="None" Width="717px"
ForeColor="#333333">
<Columns>
<asp:TemplateField
HeaderText="Select">

<ItemTemplate>
<asp:CheckBox ID="chkSelect"
AutoPostBack="true" runat="server"
OnCheckedChanged="chkSelect_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="LoginID"
HeaderText="Login Name" />
<asp:BoundField DataField="FirstName"
HeaderText="First Name" />
<asp:BoundField DataField="LastName"
HeaderText="Last Name" />
</Columns>
<PagerSettings
Mode="NextPreviousFirstLast" />
<RowStyle CssClass="row-1"
HorizontalAlign="Center" />
<SelectedRowStyle
BackColor="InactiveCaptionText" ForeColor="Black" BorderStyle="Solid"
BorderWidth="1px" HorizontalAlign="Center" VerticalAlign="Middle" />
<PagerStyle BackColor="#2461BF"
ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle"/>
<HeaderStyle BackColor="#507CD1" Font-
Bold="True" ForeColor="Black" />
<AlternatingRowStyle CssClass="row-2"
BackColor="LightGray" />
</asp:GridView>

I am not able to use same way for datagrid.

Kindly help me out.

Regards,
Abhijit B
 
D

Dathan

Hi,

I want to use CSS StyleSheet for datagrid in my web page.
The code is given below,

ASPX code:

<asp:datagrid id="grdReport" runat="server" Width="720px"
BackColor="White"
                                AutoGenerateColumns="False"
CellPadding="4" Height="22px" BorderWidth="1px" BorderStyle="None"
BorderColor="#CC9966" PageSize="5">
                                <SelectedItemStyle
BackColor="InactiveCaptionText" ForeColor="Black" />
                                <Columns>
                                    <asp:TemplateColumn
HeaderText="Select">
                                    <ItemTemplate>
                                        <asp:RadioButton
id="rdbSelect" runat="server" AutoPostBack="True"
OnCheckedChanged="SelectOnlyOne"></asp:RadioButton>
                                    </ItemTemplate>
                                    </asp:TemplateColumn>
                                    <asp:BoundColumn
DataField="LoginName" SortExpression="LoginName"
HeaderText="LoginName"></asp:BoundColumn>
                                    <asp:BoundColumn
DataField="FirstName" SortExpression="FirstName"
HeaderText="FirstName"></asp:BoundColumn>
                                    <asp:BoundColumn
DataField="LastName" SortExpression="LastName" HeaderText="LastName"></
asp:BoundColumn>
                                </Columns>
                                <ItemStyle BorderColor="Black"
ForeColor="Black" />
                                <HeaderStyle BorderColor="Black"
ForeColor="Black" />
                    </asp:datagrid>
-----------------------------------------------------
I used CSS for GridView as given below,

 <asp:GridView ID="gvSearchUsersList" runat="server" TabIndex="5"
PageSize="5" AllowPaging="True" AutoGenerateColumns="False"
OnPageIndexChanging="gvSearchUsersList_PageIndexChanging"
AllowSorting="True" GridLines="None" Width="717px"
ForeColor="#333333">
                            <Columns>
                                <asp:TemplateField
HeaderText="Select">

<ItemTemplate>
                                        <asp:CheckBox ID="chkSelect"
AutoPostBack="true" runat="server"
OnCheckedChanged="chkSelect_CheckedChanged" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="LoginID"
HeaderText="Login Name" />
                                <asp:BoundField DataField="FirstName"
HeaderText="First Name" />
                                <asp:BoundField DataField="LastName"
HeaderText="Last Name" />
                            </Columns>
                                <PagerSettings
Mode="NextPreviousFirstLast" />
                                <RowStyle CssClass="row-1"
HorizontalAlign="Center" />
                                <SelectedRowStyle
BackColor="InactiveCaptionText" ForeColor="Black" BorderStyle="Solid"
BorderWidth="1px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                <PagerStyle BackColor="#2461BF"
ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle"/>
                                <HeaderStyle BackColor="#507CD1" Font-
Bold="True" ForeColor="Black" />
                                <AlternatingRowStyle CssClass="row-2"
BackColor="LightGray" />
                        </asp:GridView>

I am not able to use same way for datagrid.

Kindly help me out.

Regards,
Abhijit B

Hi,

Have you though about using the CssClass attribute? For example
<asp:DataGrid blah=whatever CssClass="eventsGrid"/>...

Dathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,057
Messages
2,570,443
Members
47,115
Latest member
DorothyLus

Latest Threads

Top