I want to do some simple auto formatting for cells in my GridView. So far I have the following code:
Private Sub gridviewRefreshPanel_RowDataBound( _
ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
Handles gridviewRefreshPanel.RowDataBound
Dim readyStatus As String = DataBinder.Eval(e.Row.DataItem, "READY")
Select Case readyStatus
Case "NO"
e.Row.Cells.Item(5).ForeColor = Drawing.Color.Red
e.Row.Cells.Item(5).Font.Bold = True
Case "N/A"
e.Row.Cells.Item(5).ForeColor = Drawing.Color.Goldenrod
e.Row.Cells.Item(5).Font.Bold = True
Case "YES"
e.Row.Cells.Item(5).ForeColor = Drawing.Color.DarkGreen
e.Row.Cells.Item(5).Font.Bold = True
End Select
End Sub
I would like to refer to cells by column name, not by index. For example, DataRow:
row.Item("ON_TIME")
How to achieve this using GridView?
source
share