Why column count is 0 for GridView

前端 未结 5 834
春和景丽
春和景丽 2021-01-28 04:37

Friends, I\'m populating a GridView in my asp.net application using following code.

    GridView grdExport = new GridView();
    DataSet dsRecord = objHelper.gRe         


        
5条回答
  •  温柔的废话
    2021-01-28 04:39

    GridView.Columns Property

    Check this:

    The Columns property (collection) is used to store all the explicitly declared column fields that get rendered in the GridView control. You can also use the Columns collection to programmatically manage the collection of column fields.

    If you have more columns to your added columns in your grid then it will show count of those columns which you have added not the auto generated columns.

    If you show auto generated columns then it will show 0. Check this markup:

     
                
                    
                
            
    

    Now it will Show your result of columns's count to 1:
    //Before adding column to gridview

    ?dtResult.Rows.Count
    9
    ?dtResult.Columns.Count
    2
    ?GridView1.Rows.Count
    9
    ?GridView1.Columns.Count
    0
    

    After Adding column to gridview.

    ?GridView1.Columns.Count
    1
    

提交回复
热议问题