onkar walavalkar
Top achievements
Rank 1
onkar walavalkar
asked on 14 Aug 2009, 10:31 AM
hi,
i am applying css class to radgrid dynamically using .cssClass property. it works fine for all the postbacks. but if i reorder the column then page gets post back but css class does not get applied to grid. Please help me.
i am applying css class to radgrid dynamically using .cssClass property. it works fine for all the postbacks. but if i reorder the column then page gets post back but css class does not get applied to grid. Please help me.
3 Answers, 1 is accepted
0
Hi Onkar,
May be you are setting the RadGrid CssClass at an inappropriate place. Here is an example, which works:
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
May be you are setting the RadGrid CssClass at an inappropriate place. Here is an example, which works:
| <%@ Page Language="C#" %> |
| <%@ Import Namespace="System.Data" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <script runat="server"> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!IsPostBack) |
| RadGrid1.CssClass = "MyCustomClass"; |
| } |
| protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) |
| { |
| DataTable dt = new DataTable(); |
| DataRow dr; |
| int colsNum = 5; |
| int rowsNum = 10; |
| string colName = "Column"; |
| for (int j = 1; j <= colsNum; j++) |
| { |
| dt.Columns.Add(String.Format("{0}{1}", colName, j)); |
| } |
| for (int i = 1; i <= rowsNum; i++) |
| { |
| dr = dt.NewRow(); |
| for (int k = 1; k <= colsNum; k++) |
| { |
| dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i); |
| } |
| dt.Rows.Add(dr); |
| } |
| (sender as RadGrid).DataSource = dt; |
| } |
| </script> |
| <html xmlns="http://www.w3.org/1999/xhtml" > |
| <head runat="server"> |
| <meta http-equiv="content-type" content="text/html;charset=utf-8" /> |
| <title>RadControls for ASP.NET AJAX</title> |
| <style type="text/css"> |
| div.MyCustomClass |
| { |
| background:yellow; |
| } |
| </style> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <asp:ScriptManager ID="ScriptManager1" runat="server" /> |
| <telerik:RadGrid |
| ID="RadGrid1" |
| runat="server" |
| OnNeedDataSource="RadGrid_NeedDataSource"> |
| <ClientSettings AllowColumnsReorder="true" /> |
| </telerik:RadGrid> |
| </form> |
| </body> |
| </html> |
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Afzal Farooqui
Top achievements
Rank 1
answered on 02 Oct 2009, 09:01 PM
What if I have to change the cssClass of a particular item editing?
Thanks.
0
Hello Afzal,
I did not understand your question. Please clarify what exactly are you trying to do.
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I did not understand your question. Please clarify what exactly are you trying to do.
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
