Accessing DataSource on GridView RowDataBound

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?
 
D

David W

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top