GridView Column.Count is always 0 after databind with a datatable

前端 未结 3 1261
眼角桃花
眼角桃花 2021-01-14 01:37

I am trying to show/hide GridView columns conditionally.

I am creating a dynamic DataTable and then Binding it to the GridView

Later, on a post back, I am ch

3条回答
  •  温柔的废话
    2021-01-14 02:40

    Change these in ASPX page:

    1. Set the autogeneratecolumns="false".
    2. Add tags as below:
     
        
            
            
            
            
            
            
         
     
    

    In .CS file:

    int temp = GridView1.Columns.Count; // will return 6

提交回复
热议问题