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

[Solved] Grouped Title shows Integer not String.

3 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 07 Jul 2009, 02:13 PM
I hve a RadGrid which has GridTemplate Columns that have a label inside them.  The database pulls back an integer, in the code behind I change the value of the int to a string which works great.

However, when I do my grouping the integer shows up in the grouped header and not the string. 

How can I get the string to show up like it does in the grid and not the integer without having to change it in the SQL?

Thanks

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 10 Jul 2009, 05:43 AM
Hello Mike,

I am not sure I understand your question. Even if your data source returns various data types, the latter are converted into string when rendering. Could you, please elaborate.

All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mike
Top achievements
Rank 1
answered on 10 Jul 2009, 12:23 PM
In my grid I have a column titled "status"  the DataField is  "status_id".  However, I don't want to show a 1,2,3... as the status in the grid.  So, in the ItemDataBound I have a case statement to hande the DataItem and base on the integer brought back from the database I set the "item["status"].Text = "Open", etc.  This works great except when I want to group on that column.  When I drag the status column to the header for grouping the integer is displayed instead of the text. 

How do I get the text set in the ItemDataBound to show in the grouped header instead of the integer?
0
Veli
Telerik team
answered on 13 Jul 2009, 11:13 AM
Hello Mike,

Thanks for the clarification. RadGrid's ItemDataBound event does not fire after every postback. Therefore, even if you get your text on initial load, you don't on postback. You can use RadGrid's PreRender event to loop through all of your group items and change their text:

void RadGrid1_PreRender(object sender, EventArgs e) 
    foreach (GridGroupHeaderItem item in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) 
    { 
        // 
    } 


Best wishes,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Veli
Telerik team
Mike
Top achievements
Rank 1
Share this question
or