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

Column names are shown instead of column captions

1 Answer 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yo Yo What's up
Top achievements
Rank 1
Yo Yo What's up asked on 05 Feb 2009, 08:59 AM
Hi,

I'm having some issues with binding a dataset to the grid.
After I set a DataSet to be the Grid data source, The columns headers of the grid shows the dataset column names and not their captions.

I'm am developing a system that is localized so columns are translated in runtime. I don't want to translate the column name and would prefer it to be the captions.

How can this be solved?

Thank,

Eyal D.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Feb 2009, 12:41 PM
Hello Eyal,

You can access the header item and set the header text of the column as the dataset column captions, as shown below:
cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
       if (e.Item is GridHeaderItem) 
           { 
              GridHeaderItem header = (GridHeaderItem)e.Item; 
              header.Cells[0].Text = dt.Columns[0].Caption; //where dt is the DataTable in the DataSet
        
           } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Yo Yo What's up
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or