GridView - Show headers on empty data source

后端 未结 16 1335
挽巷
挽巷 2020-11-28 11:22

In C# how do I still show the headers of a gridview, even with the data source is empty.

I am not auto generating the columns as they are all predefined.

C

16条回答
  •  悲哀的现实
    2020-11-28 12:08

    ASP.Net 4.0 added the boolean ShowHeaderWhenEmpty property.

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.showheaderwhenempty.aspx


    
        
            
            
        
    
    

    Note: the headers will not appear unless DataBind() is called with something other than null.

    GridView1.DataSource = New List(Of String)
    GridView1.DataBind()
    

提交回复
热议问题