将某列内容和标题隐藏起来

protected void gvInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
switch (id)
{
case "1":
e.Row.Cells[12].Visible = false;
e.Row.Cells[13].Visible = false;
gvInfo.HeaderRow.Cells[12].Visible = false;
gvInfo.HeaderRow.Cells[13].Visible = false;
break;

case "6":
e.Row.Cells[11].Visible = false;
e.Row.Cells[12].Visible = false;
gvInfo.HeaderRow.Cells[11].Visible = false;
gvInfo.HeaderRow.Cells[12].Visible = false;
break;

default:
e.Row.Cells[11].Visible = false;
e.Row.Cells[13].Visible = false;
gvInfo.HeaderRow.Cells[11].Visible = false;
gvInfo.HeaderRow.Cells[13].Visible = false;
break;
}


}
}

你可能感兴趣的:(隐藏)