I would like to change the cell color of a specific cell in a specific row defined by two datakey values. For example using the following Grid:
Type ID Adjustments
PG 1 $10.00
V3 1 $10.00
PG 2 $134.35
V3 2 $178.60
I would like to change the background of the cells in the Adjustments column for the cells with values $134.35 and $178.60 based on the Type = PG and ID = 2 and the Type = V3 and the ID = 2. Might even get away with simply the ID = 2.
I attempted:
Protected Sub rgd_Paycheck_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles rgd_Paycheck.ItemCreated For Each item As GridDataItem In rgd_Paycheck.MasterTableView.Items Dim keyrow_PGPayrollID As String = item.GetDataKeyValue("PGPayrollID").ToString() Dim keyrow_RECTYPE As String = item.GetDataKeyValue("RECTYPE").ToString() If keyrow_PGPayrollID = 2 And keyrow_RECTYPE Like "PG" Then Dim TotalAdjustments_PG As String = item("TotalAdjustments").Text Session("TotalAdjustments_PG") = TotalAdjustments_PG End If If keyrow_PGPayrollID = 2 And keyrow_RECTYPE Like "V3" Then Dim TotalAdjustments_V3 As String = item("TotalAdjustments").Text Session("TotalAdjustments_V3") = TotalAdjustments_V3 End If If Session("TotalAdjustments_PG") <> Session("TotalAdjustments_V3") Then Label1.Text = "OOPS" If (TypeOf (e.Item) Is GridDataItem) Then 'Get the instance of the right type Dim dataBoundItem As GridDataItem = e.Item 'Check the formatting condition If keyrow_RECTYPE = "PG" Then dataBoundItem("TotalAdjustments").ForeColor = Color.Red dataBoundItem("TotalAdjustments").Font.Bold = True 'Customize more... End If End If End If Next End SubAnd attempted:
Protected Sub rgd_Paycheck_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles rgd_Paycheck.ItemDataBound If TypeOf e.Item Is GridDataItem Then Dim dataBoundItem As GridDataItem = DirectCast(e.Item, GridDataItem) If dataBoundItem.GetDataKeyValue("PGPayrollID").ToString() = "PG" And dataBoundItem.GetDataKeyValue("RECTYPE").ToString() = "V3" Then dataBoundItem("TotalAdjustments").ForeColor = Color.Red dataBoundItem("TotalAdjustments").Font.Bold = True End If End IfEnd SubAs always, any assistance much appreciated.
Allan
