Accessing DataSource on GridView RowDataBound

  • Thread starter Thread starter David W
  • Start date Start date
D

David W

I have a pretty standard bound GridView control with TemplateFields. Now I
need to be able to control the properties of some of the columns based on
values in the recordset that I am NOT displaying. Is there a way to access
the current row of the DataSource in the RowDataBound event?
 
Found it:

Sub gvWarnings_RowDataBound(ByVal sender As Object, ByVal e As
GridViewRowEventArgs) Handles gvWarnings.RowDataBound

Dim drv As Common.DbDataRecord = CType(e.Row.DataItem,
Common.DbDataRecord)
If e.Row.RowType = DataControlRowType.DataRow AndAlso drv IsNot Nothing
AndAlso gvWarnings.EditIndex = -1 Then
If drv("warninglevel") = "HIGH" Then
CType(e.Row.FindControl("btnDelete"), ImageButton).Visible =
False
End If
End If

End Sub
 
Back
Top