Hi
I have a radgrid in which , I want to set the back color of a cell in every row of one column . I need to compare the value of the cell in this column in every row of the grid and if its not the same value as the previous row cell value , I had to set different color . For example the column name is datayear , and the first row of the grid has 2013 as the second row has 2012 and so on in that cell . some time the same cell value will be repeated . so I have to compare each row cell value and set the color of the cell how can I achieve this asp.net.vb
thanks for your help
Rajeswari raman
I have a radgrid in which , I want to set the back color of a cell in every row of one column . I need to compare the value of the cell in this column in every row of the grid and if its not the same value as the previous row cell value , I had to set different color . For example the column name is datayear , and the first row of the grid has 2013 as the second row has 2012 and so on in that cell . some time the same cell value will be repeated . so I have to compare each row cell value and set the color of the cell how can I achieve this asp.net.vb
thanks for your help
Rajeswari raman
5 Answers, 1 is accepted
0
Hi Rajeswari,
You can achieve the requested functionality using the following approach:
Hope this helps. Please give it a try and let me know if it works for you.
Regards,
Eyup
Telerik
You can achieve the requested functionality using the following approach:
Protected Sub RadGrid1_DataBound(sender As Object, e As EventArgs) Dim value As String = "" For Each item As GridDataItem In RadGrid1.MasterTableView.Items Dim cell As TableCell = item("ShipCountry") If Not cell.Text = value Then value = cell.Text cell.BackColor = System.Drawing.Color.LightBlue End If NextEnd SubHope this helps. Please give it a try and let me know if it works for you.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Rajeswari
Top achievements
Rank 1
answered on 02 Feb 2015, 04:13 PM
Thanks. I have a radgrid with lot of numerical columns , if the user chooses whole numbers form the drop down in the page , I have to format the numerical columns in the radgrid, without any decimal places. I am not able to get the correct results for whole numbers in the grid , if the database value is 223,817,128 , it is always formatting with zero (223,817,128.0) How can I format to get with out any zeros .The grid is set to autogeneratedcolumns to true. I have to do it columncreated event of the grid in code behind. I am using vb.net Thanks for your help.
Rajeswari Raman
Rajeswari Raman
0
Hello Rajeswari,
You can use the following format:
Hope this helps.
Regards,
Eyup
Telerik
You can use the following format:
Protected Sub RadGrid1_ColumnCreated(sender As Object, e As GridColumnCreatedEventArgs) If e.Column.UniqueName = "Freight" Then TryCast(e.Column, GridNumericColumn).DataFormatString = "{0:N0}" End IfEnd SubHope this helps.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Rajeswari
Top achievements
Rank 1
answered on 05 Feb 2015, 03:37 PM
Thanks for your help . I have another radgrid in the page with autogenratecolumns set to true and showheaders set to false . I have to do the dataformatstring for some rows (which has financial data) in the grid based on some condition in the page
I have to do it in the itemdatabound only, How can I access the rows in the itemdatabound and set the data format string for some cells only based on the condition Is there any sample code Thanks for your help
Rajeswari Raman
I have to do it in the itemdatabound only, How can I access the rows in the itemdatabound and set the data format string for some cells only based on the condition Is there any sample code Thanks for your help
Rajeswari Raman
0
Hi Rajeswari,
You can use the following modification:
That should do the trick. Looking forward to your reply.
Regards,
Eyup
Telerik
You can use the following modification:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = TryCast(e.Item, GridDataItem) Dim value As System.Nullable(Of Decimal) = DirectCast(DataBinder.Eval(item.DataItem, "Freight"), Nullable(Of Decimal)) If value.HasValue AndAlso value > 5 Then item("Freight").Text = String.Format("{0:N0}", value) End If End IfEnd SubThat should do the trick. Looking forward to your reply.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
