This is a migrated thread and some comments may be shown as answers.

Rad Grid Footer Validation

2 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alessandro
Top achievements
Rank 1
Alessandro asked on 01 Nov 2011, 02:33 PM
HI,

I have a radgrid which shows numeric data.

I agregate this data with the sum function and it shows in the footer the total.

Now I need to validate the footer.
When it is negative it needs to be red, and when it is positive in need to be black.

I am doing this in VB.net.

Is there anyway to call the footer text for a specific column on the code behind?
or is there a special data format string that will change the color of the text when it is negative?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 01 Nov 2011, 03:15 PM
Hello Alessandro,

You can try the following code snippet.

VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)
 If TypeOf e.Item Is GridFooterItem Then
  Dim fitem As GridFooterItem = TryCast(e.Item, GridFooterItem)
  Dim value1 As String = fitem("ColUniqueName").Text
  Dim footervalue As Integer = Convert.ToInt32(value1.Split(":"C)(1))
  'to get the value only.
  If footervalue > 0 Then
   fitem("ColUniqueName").Style("color") = "Black"
  Else
   fitem("ColUniqueName").Style("color") = "Red"
  End If
 End If
End Sub

Thanks,
Princy.
0
Alessandro
Top achievements
Rank 1
answered on 01 Nov 2011, 04:37 PM
Hi Princy actually did this:

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
If TypeOf e.Item Is GridFooterItem Then
            Dim gridfooteritem As GridFooterItem = e.Item
            If gridfooteritem("BALANCE").Text < 0 Then
                gridfooteritem("BALANCE").ForeColor = Drawing.Color.Red
            End If
            If gridfooteritem("THIS_WEEK_FIGURES").Text < 0 Then
                gridfooteritem("THIS_WEEK_FIGURES").ForeColor = Drawing.Color.Red
            End If
            If gridfooteritem("THIS_WEEK_PAYMENTS").Text < 0 Then
                gridfooteritem("THIS_WEEK_PAYMENTS").ForeColor = Drawing.Color.Red
            End If
            If gridfooteritem("LAST_WEEK_FIGURES").Text < 0 Then
                gridfooteritem("LAST_WEEK_FIGURES").ForeColor = Drawing.Color.Red
            End If
            If gridfooteritem("LAST_WEEK_PAYMENTS").Text < 0 Then
                gridfooteritem("LAST_WEEK_PAYMENTS").ForeColor = Drawing.Color.Red
            End If
End Sub

It works great, but your code will also work.
Tags
Grid
Asked by
Alessandro
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Alessandro
Top achievements
Rank 1
Share this question
or