# Template / Format for Group Header

**URL:** <https://forum.radzen.com/t/template-format-for-group-header/20054>\
**Category:** Radzen.Blazor Components\
**Created:** [March 31, 2025, 9:05am UTC](https://forum.radzen.com/t/template-format-for-group-header/20054 "2025-03-31T09:05:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [March 31, 2025, 9:05am UTC](https://forum.radzen.com/t/template-format-for-group-header/20054/1 "2025-03-31T09:05:15Z")

</div>

Hi,

I have a DataGrid which has a Column "LinkedContactId" (int).

I created custom template which is a label using data from a foreign key table to display a company name instead of the ID: LinkedAccount.Contact.Company

So in the grid, I see the company name instead of the ID.

Now, when I enable grouping for this column, I can group which also works fine. However, in the grouping header, it still uses the ID, so it says e.g.:

Linked Contact: 123

I would like to also show the company name here as well instead of the ID which is actually being used for grouping. Is there a simular concept like the column template for the grouping header?

I also tried to set LinkedAccount.Contact.Company as GroupingProperty but this fails since not every record in the table has a value set for LinkedAccount and therefore, I get a null ref exeception.

Any ideas how to "format" the group header/label?

Thanks!

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [March 31, 2025, 9:56am UTC](https://forum.radzen.com/t/template-format-for-group-header/20054/2 "2025-03-31T09:56:43Z")

</div>

As any other C# expression you can use null check operator when accessing sub properties - i.e. ?.

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [March 31, 2025, 11:06am UTC](https://forum.radzen.com/t/template-format-for-group-header/20054/3 "2025-03-31T11:06:34Z")

</div>

That was also my first thought but this seems not to work on GroupPropertry. I get this error:

System.ArgumentException: 'LinkedAccount?' is not a member of type 'MyApp.Models.MyAppData.Account' (Parameter 'propertyOrFieldName')

I tried these expressions for GroupProperty:

LinkedAccount?.Contact.Company  
LinkedAccount.Contact?.Company  
LinkedAccount?.Contact?.Company

They all fail because the field with the ? operator attached is not recognized.

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [March 31, 2025, 11:19am UTC](https://forum.radzen.com/t/template-format-for-group-header/20054/4 "2025-03-31T11:19:06Z")

</div>

There is such expression in this demo:  
[https://blazor.radzen.com/datagrid-group-header-template](https://blazor.radzen.com/datagrid-group-header-template)
