Live Chat Icon For mobile
Live Chat Icon

How to hide a column in a Datagrid if AutoGenerateColumns is set to True?

Platform: ASP.NET| Category: DataGrid

<asp:DataGrid id='DataGrid1' onItemDataBound='ItemDB' runat='server'></asp:DataGrid>

VB.NET


protected Sub ItemDB (ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
             e.Item.Cells(0).Visible = False
End Sub

C#


protected void ItemDB (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
            e.Item.Cells[0].Visible = false;
}

Share with

Share on twitter
Share on facebook
Share on linkedin