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

[Solved] Change row background to picture

3 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 23 Apr 2013, 08:24 PM
I am trying to change the row background to a picture if the cell text equals EOL.  Tried changing the attributes but cannot find the correct syntax.  and is there a way to format the size of the jpg doing this as well to change the height and width.

Protected Sub myRadGrid_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles myRadGrid.ItemDataBound
       If TypeOf e.Item Is GridDataItem Then
           Dim item As GridDataItem = CType(e.Item, GridDataItem)
           Dim Cell As TableCell = item("Type")
           Dim text As String = Cell.Text
 
           If text = "EOL" Then
               item.Attributes.Add(Style.background = "../Images/wallpaper_big-wDD_cs.jpg")
           End If
       End If
   End Sub

3 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 23 Apr 2013, 08:29 PM
Ok, found this solution to add the picture, but have not found a way to set the hheight and width sot hat the picture comes out looking good, because the picture is bigger than the row, so its distorted, is there a way to change.

Protected Sub myRadGrid_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles myRadGrid.ItemDataBound
       If TypeOf e.Item Is GridDataItem Then
           Dim item As GridDataItem = CType(e.Item, GridDataItem)
           Dim Cell As TableCell = item("Type")
           Dim text As String = Cell.Text
 
           If text = "EOL" Then
               item.Attributes.Add("Style", "background: url(../Images/wallpaper_big-wDD_cs.jpg) no-repeat 5px center;")
           End If
       End If
   End Sub
0
Kevin
Top achievements
Rank 1
answered on 23 Apr 2013, 08:39 PM
instead of a picture would it be possible to change to background color but to make it multi color so I can make it like a rainbow.
0
Princy
Top achievements
Rank 2
answered on 24 Apr 2013, 03:21 AM
Hi Kevin,

You can provide background color for the row depending on the text in a cell as follows.

VB:
Protected Sub myRadGrid_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim Cell As TableCell = item("Type")
        Dim text As String = Cell.Text
        If text = "EOL" Then               
            item.BackColor = Color.Red
            'giving background color to row
        End If
    End If
End Sub

Please elaborate the scenario if it doesn't help.

Thanks,
Princy.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or