Hi, I have a child gridview with a linkbutton where I'm trying to hide the linkbutton if e.Row.Cells(0) is empty. I'm able to find the linkbutton on a standalone gridview, but nested appears to be different. (edit: current error is "lnkbtn object reference not set to an instance of an object). Thanks in advance.
Protected Sub gvDepartment_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvDepartment.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim id As String = gvDepartment.DataKeys(e.Row.RowIndex).Value.ToString()
Dim gvChild As GridView = TryCast(e.Row.FindControl("gvEmployees"), GridView)
gvChild.DataSource = GetData2(String.Format("SELECT * FROM tblFiles WHERE ID='{0}'", id)) gvChild.DataBind() gvChild.Columns(4).ItemStyle.Wrap = False
Dim lbRT As LinkButton = TryCast(Me.Master.FindControl("Maincontent").FindControl("lnkDownload"), LinkButton)
'e.Row.BackColor = Color.Gray
If gvChild IsNot Nothing Then
Dim lnkbtn As LinkButton = TryCast(e.Row.FindControl("lnkDownload"), LinkButton)
For Each row As GridViewRow In gvChild.Rows
If e.Row.Cells(0).Text.Equals(" ") Then
lnkbtn.Visible = False
End If
Next
End Sub