How to show/hide column in GridView
1. To hide a column just set the width to 0. To show it again set the width to auto.
Code:
GridView1.Columns[0].ItemStyle.Width = 0;
2. Hide the column
Code:
GridView1.Columns[6].Visible = false;
3. Different way to Hide the columns
Code:
protected void Gridview1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Visible = false;
}
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false;
}
}
No comments:
Post a Comment