Hiding Columns of Gridview in ASP.NET

  • In the RowCreated event for that datagrid put these codes below:

    If e.Row.RowType = DataControlRowType.DataRow Then
    e.Row.Cells(5).Attributes.CssStyle.Add(”display”, “none”)
    End If

  • In the Databound event for the datagrid put these:

    If GridLeaveDates.Rows.Count > 0 Then
    GridLeaveDates.HeaderRow.Cells(5).Visible = False
    End If

———————————————————————————

if (dg.Rows.Count > 0 )
{
dg.HeaderRow.Cells[2].Visible = false;
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s