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

HOW TO SHOW HEADER OF RAD GRID

4 Answers 353 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 2
Ajay asked on 30 Jul 2009, 06:01 AM
Hi Telerik Guys !

Guys ! Iam using the Q2 2009 version for the ASP.NET RAD CONTROLS

I have set the SKIN property to DEFAULT for the  RAD GRID.

Im using DATA TABLE to bind it with OBJECT DATA SOURCE.

I have used  all the mentioned solution provided at your end , but all in vain.

Could you plz help me how to show up the header of the grid .

Right now , RAD GRID is behaving just like a HORIZONTAL SCROLL BAR.

Below is the code that I have been using :-
.CS File :-
//

At Page_Load :

  SearchResultsRadGrid.MasterTableView.GetColumn("RowIndicator").Display = false;

//

protected void SearchResultsRadGrid_PreRender(object sender, EventArgs e)
        {
            SearchResultsRadGrid.MasterTableView.ShowHeadersWhenNoRecords = true;
           
        }


Help !

Ajay Jamwal

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jul 2009, 07:02 AM
Hello Ajay,

The RadGrid may appear as a horizontal line when the datasource for the RadGrid is null(when no records) initially. Inorder to display the header row of the grid even when the grid's datasource is not assigned, you can try the following code:
c#:
 if (RadGrid1.DataSource == null)  
        {  
            RadGrid1.DataSource = new string[] { };  
        }  
Additionally, you can declaratively set the ShowHeadersWhenNoRecords property also to True.

Hope this helps...
Shinu.
0
Ajay
Top achievements
Rank 2
answered on 30 Jul 2009, 07:16 AM
hi shinu !

I have put that code on to Page Load as well as on to the Grid Pre-Render event , but nothing working

It just displays the following message :-

"Both DataSource and DataSourceID are defined on 'ctl00'.  Remove one definition."

I have the following code at the RadGrid :-

<telerik:RadGrid ID="SearchResultsRadGrid" AllowSorting="true" runat="server" Width="98%" GridLines="Vertical"
                SkinID="RadGridHeaderSkin" Style="margin: 10px  10px 10px 10px" OnPreRender="SearchResultsRadGrid_PreRender" OnItemDataBound="SearchResultsRadGrid_ItemDataBound"
                DataSourceID="TherapeuticObjectDataSource" OnSelectedIndexChanged="SearchResultsRadGrid_SelectedIndexChanged">

(That is, only DataSourceID  is provided.)

Its not working .

Please help !
0
Amresh Kumar
Top achievements
Rank 1
answered on 05 Jan 2010, 11:19 AM
Hi Ajay

Whatever u have done is looks alright. I want to confirm one thing whether you are putting any validation before binding with grid.
This will work only when Radgrid.datasource = datatable or dataset will execute.

Before executing dont put any condition whether data is there or not in datatable or dataset.

ShowHeadersWhenNoRecords = true

Regards
Amresh
0
atefe mohamadzade
Top achievements
Rank 1
answered on 13 Jun 2010, 08:35 AM
hi
my datasource is null when i fire it grid dont show
and i can't add new record
i tried this skill but not answered
please help me
Tags
Grid
Asked by
Ajay
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Ajay
Top achievements
Rank 2
Amresh Kumar
Top achievements
Rank 1
atefe mohamadzade
Top achievements
Rank 1
Share this question
or