Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Autogenerated Column in Gridview

I have a gridview that uses autogenerated columns, because the user can select the columns to return in a query. I want to hide the column with the identity. How do I hide the autogenerated column? Even in the databound event the columns count is zero.

like image 726
SchwartzE Avatar asked Sep 15 '09 15:09

SchwartzE


1 Answers

I discovered how to do this. You need to use the rowdatabound event and hide the cell when the row is bound.

Protected Sub ResultGrid_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles ResultGrid.RowDataBound
        e.Row.Cells(1).Visible = False
End Sub
like image 166
SchwartzE Avatar answered Sep 29 '22 16:09

SchwartzE