My GridView is as follows
It has EmptyDatatemplate and Command Field
<asp:GridView ID="AGridView" runat="server" AutoGenerateColumns="true" style="table-layout:fixed;" Width="2000px" RowStyle-HorizontalAlign="Left">
<EmptyDataTemplate>
</EmptyDataTemplate>
<asp:CommandField ShowEditButton="True" ItemStyle-Width="80px" EditText="Edit">
<ItemStyle Font-Bold="true" Font-Size="Small" />
<HeaderStyle CssClass="AAddOn" />
</asp:CommandField>
</asp:GridView>
GridView Looks like(it has only 2 rows)
Name Age Country
A 10 NNN Edit
B 23 NNN Edit
Now i dont need Edit Button to be displayed in first row.How can i do it.
Only 2 rows will be displayed here.
Name Age Country
A 10 NNN
B 23 NNN Edit
Here header is count of Gridview Header cells and my edit is in last cell. (My Gridview generated dynamically generated columns but has only 2 rows so i cannot take fixed column values hence used header count)
Dim Header As Integer
For counts = 0 To AGridView.HeaderRow.Cells.Count
Header = counts
Next
Dim edit as LinkButton = DirectCast(AGridView.Rows(0).cell(header).FindControl("Edit"),LinkButton)
edit.Visible = False
Error message for above is Object reference not set to instance.Index is out of range.
Next I have tried inside AGridView_Rowdatabound as but whole cell is disappearing .I need only First row edit linkbutton visible to be false
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(Header).Visible = False
End If
What am i missing here.I need only First row edit button visible to be false.