5 Answers, 1 is accepted
Try the following code snippet.
CS:
| public static string user; |
| protected void RadGrid1_PreRender(object sender, EventArgs e) |
| { |
| if (user == "Admin") |
| { |
| RadGrid1.BackColor = System.Drawing.Color.Red; |
| } |
| else |
| RadGrid1.BackColor = System.Drawing.Color.LightBlue; |
| } |
Thanks
Shinu.
Please note that setting a new color and background color to RadGrid does not guarantee that they will become visible. This is because there are background colors and images set to the table rows, which are on top of the RadGrid container <div>.
The new color may not become visible for similar reasons.
After all, it depends on the skin, so let us know if you have any troubles and we will tell you how to proceed.
Best wishes,
Dimo
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
<
telerik:RadGrid ID="grdPosition1" runat="server" Font-Names="Arial" OnItemCreated="grdPosition1_ItemCreated"
OnItemCommand="grdPosition1_ItemCommand" AllowPaging="True" PageSize="100" OnNeedDataSource="grdPosition1_NeedDataSource"
Font-Size="8pt" GridLines="None" AutoGenerateColumns="False" OnItemDataBound="grdPosition1_ItemDataBound"
ShowFooter="true" OnPageIndexChanged="grdPosition1_PageIndexChanged" OnExcelMLExportRowCreated="grdPosition1_ExcelMLExportRowCreated"
OnExcelMLExportStylesCreated="grdPosition1_ExcelMLExportStylesCreated" Skin="Web20">
Even if i don't specify any skin it is getting the default skin and my CSSClass has no effect on the grid 's header color.
So i have set the header using the SetRenderMethodDelegate.
But i have dynamic columns too, so instead of so much of coding...is there any other way we could override the Grid's header CSS Class.
Thanks in advance.
If the styles defined by the custom CSS class are overridden by the skin, then please refer to the following blog post, which explains why this happens and how to avoid this:
How To Override Styles in a RadControl for ASP.NET AJAX Embedded Skin
Basically, if you are setting a custom CSS class to the header cells, you should use the following CSS rule to define custom styles:
div.RadGrid_Web20 .MyCustomHeaderClass
{
}
Let us know if you still have troubles with that.
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
It worked perfectly.
Thank you so much.
