How to hide columns in an ASP.NET GridView with auto-generated columns?

前端 未结 12 1676
陌清茗
陌清茗 2020-11-30 08:28

GridView1.Columns.Count is always zero even SqlDataSource1.DataBind();

But Grid is ok

I can do

for (int i = 0; i < GridView1.HeaderRow.Cel         


        
12条回答
  •  Happy的楠姐
    2020-11-30 09:02

    In the rowdatabound method for 2nd column

    GridView gv = (sender as GridView);
    gv.HeaderRow.Cells[2].Visible = false;
    e.Row.Cells[2].Visible = false;
    

提交回复
热议问题