在RowCreated事件中书写如下代码
void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow ||
e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false; //如果想使第1列不可见,则将它的可见性设为false
}
//可以根据需要设置更多的列
}
void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow ||
e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false; //如果想使第1列不可见,则将它的可见性设为false
}
//可以根据需要设置更多的列
}