I am working on a gridview in netadvantage 5.3. I need to put an image in a cell to denote a certain instance in the record. How do I do that or can it be done with this control version? Please help and respond asap.
Thanks so much in advance.
I've done it this way...
Gridname.Columns.FromKey("keyname").CellStyle.BackgroundImage = "images/yourImage.gif"
I hope that helps. Good luck!
Hey.... thanks for the reply. I tried that and it worked... but it put the same image in every row cell. I have a case select statement in my for next but it still gives me the same image in each cell in the column. Any ideas? Here's the code of what I'm trying to achieve:
Me.UltraWebGrid1.DataBind() 'For Each row As DataGridItem In UltraWebGrid1.Items ' If row.Cells(4).Text = "PRIORITY" Then ' row.ForeColor = Color.Red ' End If 'Next
Dim img00 As String = "~/Images/Symbol Exclamation 1.png" Dim img100 As String = "~/Images/phone-button-green_16x16.png" Dim img200 As String = "~/Images/phone-button-blue_16x16.png" Dim img300 As String = "~/Images/phone-button-yellow_16x16.png" Dim img911 As String = "~/Images/phone-button-red_16x16.png"
For Each row As Infragistics.WebUI.UltraWebGrid.UltraGridRow In UltraWebGrid1.Rows
Dim x As String = row.Cells.FromKey("StatusNumber").Value
Select Case x
Case "" UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Transparent UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img00 UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.CustomRules = "Background-repeat:no-repeat" UltraWebGrid1.Columns(0).Header.Style.CustomRules = "align:center" UltraWebGrid1.Columns(0).CellStyle.HorizontalAlign = HorizontalAlign.Center
Case "100"
'row.Style.ForeColor = Color.Red 'row.Style.BackColor = Color.Yellow UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Transparent UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img100 UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.CustomRules = "Background-repeat:no-repeat" UltraWebGrid1.Columns(0).Header.Style.CustomRules = "align:center" UltraWebGrid1.Columns(0).CellStyle.HorizontalAlign = HorizontalAlign.Center
Case "200" ' row.Style.ForeColor = Color.Red ' row.Style.BackColor = Color.Yellow UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Transparent() UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img200 UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.CustomRules = "Background-repeat:no-repeat" UltraWebGrid1.Columns(0).Header.Style.CustomRules = "align:center" UltraWebGrid1.Columns(0).CellStyle.HorizontalAlign = HorizontalAlign.Center
Case "300"
row.Style.ForeColor = Color.Yellow row.Style.BackColor = Color.Black UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Black() UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img300 UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.CustomRules = "Background-repeat:no-repeat" UltraWebGrid1.Columns(0).Header.Style.CustomRules = "align:center" UltraWebGrid1.Columns(0).CellStyle.HorizontalAlign = HorizontalAlign.Center
Case "911"
row.Style.ForeColor = Color.Red row.Style.BackColor = Color.Yellow row.Style.Font.Bold = True
UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Yellow() UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img911 UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.CustomRules = "Background-repeat:no-repeat" UltraWebGrid1.Columns(0).Header.Style.CustomRules = "align:center" UltraWebGrid1.Columns(0).CellStyle.HorizontalAlign = HorizontalAlign.Center
End Select
If row.Cells.FromKey("Status").Value = "PRIORITY" Then row.Style.ForeColor = Color.LightBlue row.Style.BackColor = Color.Navy
End If
Next txtCount.Text = DataSet11.WebCalls.Rows.Count.ToString & " Call(s) Found" End Sub
Thanks again.
Where are you calling that code? Have you tried it in the InitializeRow event? That event will be fired once for each row in the grid.
Sorry for the delay in responding - working from home today with a sick child! Anyway, I took your advise and used the InitializeRow event and got the following... "System.InvalidCastException: Specified cast is not valid."
Here's what I wrote... the code craps out at the "Line 289: For Each e In UltraWebGrid1.Rows"
I have absolutely no idea what I'm doing wrong... it's probably looking right at me! I really appreciate all your help.
J______________________________________________________________________________________________________________________Code:
Dim img00 As String = "~/Images/Symbol Exclamation 1.png"
Dim img200 As String = "~/Images/phone-button-blue_16x16.png"
Dim img911 As String = "~/Images/phone-button-red_16x16.png"
'Dim x As String = e.Cells.FromKey("StatusNumber").Value
UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Transparent
UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img00
UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.CustomRules = "Background-repeat:no-repeat"
UltraWebGrid1.Columns(0).Header.Style.CustomRules = "align:center"
UltraWebGrid1.Columns(0).CellStyle.HorizontalAlign = HorizontalAlign.Center
'row.Style.ForeColor = Color.Red
'row.Style.BackColor = Color.Yellow
e.Row.Cells(0).Style.BackgroundImage = img100
UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img100
'UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.CustomRules = "Background-repeat:no-repeat"
' row.Style.ForeColor = Color.Red
' row.Style.BackColor = Color.Yellow
UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Transparent()
e.Row.Cells(0).Style.BackgroundImage = img200
'UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img200
e.Row.Style.ForeColor = Color.Yellow
e.Row.Style.BackColor = Color.Black
UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Black()
e.Row.Cells(0).Style.BackgroundImage = img300
'UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img300
e.Row.Style.ForeColor = Color.Red
e.Row.Style.BackColor = Color.Yellow
'UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.ForeColor = Color.Yellow()
'UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.IsEmpty()
UltraWebGrid1.Columns(0).CellStyle.ForeColor = Color.Transparent
e.Row.Cells(0).Style.BackgroundImage = img911
'UltraWebGrid1.Columns.FromKey("StatusNumber").CellStyle.BackgroundImage = img911
If e.Row.Cells.FromKey("Status").Value = "PRIORITY" Then
e.Row.Style.ForeColor = Color.LightBlue
e.row.Style.BackColor = Color.Navy
Next
I just figured out what it was... I had to take the For... Next out. The event rolls through each row so I didn't need to loop through it! DUH.
Thanks for all your help and perspective!
J
usxpress said: I just figured out what it was... I had to take the For... Next out. The event rolls through each row so I didn't need to loop through it! DUH. Thanks for all your help and perspective! J
Whoops, looks like I was a little late on my response! I'm glad you got it working.