This is a migrated thread and some comments may be shown as answers.

Show Header when no data

3 Answers 232 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 15 Jun 2009, 09:53 PM
Is it possible to show the column headers when the grid is not connected to a datasource?  I would like to show in my wireframe were the grid will reside, but it shrinks when there is no data.


3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 16 Jun 2009, 04:39 AM
Hello Chris,

You can set the ShowHeadersWhenNoRecords property of the ownertableview to true.
aspx:
 <telerik:RadGrid ID="RadGrid2" runat="server" >       
    <MasterTableView ShowHeadersWhenNoRecords="true"  > 

Also when the datasource for the RadGrid is null(when no records), you can try setting it as shown below:
c#:
      if (RadGrid1.DataSource == null)  
        {  
            RadGrid1.DataSource = new string[] { };  
        }  

Thanks
Princy.
0
Chris
Top achievements
Rank 1
answered on 16 Jun 2009, 09:50 PM
That works but what if the grid is in a RadPageView or what if it's in FormTemplate inside a RadePageView.  How would I access RadGrid1.DataSource ?


0
Princy
Top achievements
Rank 1
answered on 17 Jun 2009, 06:02 AM
Hello Chris,

When the RadGrid is placed in the RadPageView, you can directly access the grid and set its DataSource using its ID:
aspx:
 <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0" RenderSelectedPageOnly="false"
       <telerik:RadPageView runat="server" ID="RadPageView1">                                        
          <telerik:RadGrid ID="RadGrid1" AllowPaging="true" PageSize="5" AutoGenerateColumns="true" runat="server"
                        <MasterTableView> 
                        </MasterTableView> 
           </telerik:RadGrid> 
        </telerik:RadPageView> 
        <telerik:RadPageView ID="RadPageView2" runat="server"
                    Any Text:                    
                    <br /> 
                    Any Number:                    
        </telerik:RadPageView> 
 </telerik:RadMultiPage> 

c#:
RadGrid1.DataSource = dt; 

If the RadGrid is nested inside a FormTemplate, then you can access the FormTemplate and then using its FindControl() method access the RadGrid.
If this does not help, consider pasting your aspx code here.

Thanks
Princy.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Share this question
or