I have a Griview which i bind dynamically. The fisrt column is the ID and i have a button to do things when the user press it depend on the ID of the row. I want to hide that column. I try every solution i found here how to change the column width but i can hide it or set it to 0. I try the
Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
e.Row.Cells(1).Width = New Unit("1px")
End If
The code is working because if i type 1000px then its wider but i can't make it 0. The code for the grid is
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false" Font-Size="Small" ShowFooter="True" Width="100%" GridLines="Both" BorderStyle="Solid" HeaderStyle-HorizontalAlign ="Center" >
<Columns>
<asp:ButtonField ButtonType="Button" CommandName="AddToBasket" Text="" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" ShowHeader="False" SortExpression="ID" Visible="true" />
What i'm doing wrong?