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

Change display text of a group

2 Answers 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dany V
Top achievements
Rank 1
Dany V asked on 05 Apr 2010, 11:26 PM
Hi,

By now I'm grouping by expressions programmatically, what I want to do is to change the text displayed on the group header, I mean, I'm doing this:

Dim expression As GridGroupByExpression = GridGroupByExpression.Parse("PROJECT[Project ID] Group by PROJECT"

so the result in the grid is like this: "Project ID: Project1" (being Project1 the field in the database), but what happen if the field of the database, PROJECT, is empty? the result will be: "Project ID: "; is there a way to write "Empty" instead of " "(blank)???...I don't want to modify the database.

Thanks in advance!

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Apr 2010, 06:13 AM
Hello Daniel,

You can try the following code snippet in ItemDataBound event in order to change the GroupHeader text if the field is blank.

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridGroupHeaderItem) 
    { 
        GridGroupHeaderItem headeritem = (GridGroupHeaderItem)e.Item; 
        if (headeritem.DataCell.Text =="ProjectID: "
        { 
            headeritem.DataCell.Text = "Empty"; 
        } 
    } 

Hope this helps,
Shinu.
0
Dany V
Top achievements
Rank 1
answered on 06 Apr 2010, 03:13 PM
thanks Shinu!!! exactly what I wanted =)
Tags
Grid
Asked by
Dany V
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dany V
Top achievements
Rank 1
Share this question
or