Question : GridView hide button onRowDataBound

I am trying to hide a button on row databound of gridview control


                   
                   
                    />
                   
                   
                         SortExpression="str_StatusName" />
                   
                   
                       
                           
                                                   

                       
                   


               


 protected void AllProjects_RowDataBound(Object sender, GridViewRowEventArgs e)
        {
           
            LinkButton btn = ((LinkButton)(e.Row.FindControl("Editt")));
            btn.Visible = true;

        }


every time i try to reference my Editt button I get a null reference exception ... any ideas?

Answer : GridView hide button onRowDataBound

Here is my complete code for disabling a button ......vb syntax


  Public Sub DisableButton(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim DateEdit As ImageButton = CType(e.Row.FindControl("btnDateEdit"), ImageButton)
            DateEdit.Enabled = False
        End If
     
    End Sub
Random Solutions  
 
programming4us programming4us