Soldato
Hmm;
I thought this would be simple but nahh.
Gridview is populated from a sqldatasource and I'm just trying to format the row/cell based on cell value containing part of a string. e.g. "VM" cell contains "123AAA321".
I've tried various combinations of code but nothing doing! any pointers most welcome!
I thought this would be simple but nahh.
Gridview is populated from a sqldatasource and I'm just trying to format the row/cell based on cell value containing part of a string. e.g. "VM" cell contains "123AAA321".
Code:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.SelectedIndexChanged
If e.Row.RowType = DataControlRowType.DataRow Then
Dim view As DataRowView = DirectCast(e.Row.DataItem, DataRowView)
Select Case True
Case (Convert.ToString(view("VM"))).Contains("AAA")
e.Row.BackColor = System.Drawing.Color.Green
Exit Select
Case (Convert.ToString(view("VM"))).Contains("BBB")
e.Row.BackColor = System.Drawing.Color.Orange
Exit Select
Case (Convert.ToString(view("VM"))).Contains("CCC")
e.Row.BackColor = System.Drawing.Color.Red
Exit Select
End Select
End If
End Sub
I've tried various combinations of code but nothing doing! any pointers most welcome!