# Problem in Blazor DataGrid with Custom Classes

**URL:** <https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124>\
**Category:** Blazor Server\
**Created:** [April 2, 2020, 5:25pm UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124 "2020-04-02T17:25:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Levi\_Barrocas](https://forum.radzen.com/user_avatar/forum.radzen.com/levi_barrocas/32/1287_2.png) [@Levi\_Barrocas](https://forum.radzen.com/u/Levi_Barrocas)\
**Post date:** [April 2, 2020, 5:25pm UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/1 "2020-04-02T17:25:28Z")

</div>

Just for fun I am trying to move a project from Angular to Blazor to see some of the advantages.  
I am running into an issue though.  
I have a class called "Character" for an RPG system. That class is on the namespace "BlazorProject" as such I call it using "BlazorProject.Character".  
I call the function GetCharacters on Radzen which is pretty simple:

> public IEnumerable\<BlazorProject.Character\> GetCharacters(){  
> MongoClient client = new MongoClient(connectionString);  
> var database = client.GetDatabase("RPGBot");  
> return database.GetCollection\<BlazorProject.Character\>("Characters").AsQueryable().ToList();  
> }

I call the function on the Invoke Method function on Load.  
Up to here it builds just fine.  
When I put a datagrid though to be able to see these values on the page... I get an error.  
On the designer page the datagrid gets generated like this:  
protected RadzenGrid\<BlazorProject.Models.Character.Character\> grid0;  
Which is... clearly completely wrong.  
Why does this happen? Am I doing something very wrong?

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [April 2, 2020, 7:22pm UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/2 "2020-04-02T19:22:09Z")

</div>

We fixed a similar issue with today's release 2.44.9. Try upgrading it ([you have to manually download it though](http://forum.radzen.com/t/the-application-window-crashes/3107/7)). Then add the DataGrid again and set its Data property. The type should be correct this time.

---

<div class="post-metadata">

**Author:** ![Levi\_Barrocas](https://forum.radzen.com/user_avatar/forum.radzen.com/levi_barrocas/32/1287_2.png) [@Levi\_Barrocas](https://forum.radzen.com/u/Levi_Barrocas)\
**Post date:** [April 2, 2020, 7:36pm UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/3 "2020-04-02T19:36:02Z")

</div>

Sadly I did update just before filing this error, in fact I tried to do this again today exactly because I saw that patch. I will try again in a few hours.

---

<div class="post-metadata">

**Author:** ![Levi\_Barrocas](https://forum.radzen.com/user_avatar/forum.radzen.com/levi_barrocas/32/1287_2.png) [@Levi\_Barrocas](https://forum.radzen.com/u/Levi_Barrocas)\
**Post date:** [April 2, 2020, 8:00pm UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/4 "2020-04-02T20:00:27Z")

</div>

See on the result page for the command:

 ![image](https://forum.radzen.com/uploads/default/original/2X/4/4e7eec1e10e3fa42d0cd6eb0d80caf82aec1d7aa.png)  
Completely right  
Here:  
 ![image](https://forum.radzen.com/uploads/default/original/2X/3/3fbd377c19fbdb44f23654f90035460cf6804fd5.png)  
Seems right.  
Here:  
 ![image](https://forum.radzen.com/uploads/default/original/2X/b/b591a6ce119e669988c5d088171b16cf8e4d2228.png)  
Wrong.  
Version of Radzen:  
 ![image](https://forum.radzen.com/uploads/default/original/2X/8/82f1614d058d53b93820568f24bcddf2320f832c.png)

Same error happens with DataList  
Making a Label and puttin it's text component to ${Variable1.ToArray()[0].Name} Works though.  
If I add them to the code generation ignore list and remove the bogus class names it does work. Kinda.

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [April 3, 2020, 5:05am UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/5 "2020-04-03T05:05:39Z")

</div>

Try adding a custom attribute TItem to the DataGrid with the correct class name. It should override the autodetected one. We will investigate a possible fix.

---

<div class="post-metadata">

**Author:** ![Levi\_Barrocas](https://forum.radzen.com/user_avatar/forum.radzen.com/levi_barrocas/32/1287_2.png) [@Levi\_Barrocas](https://forum.radzen.com/u/Levi_Barrocas)\
**Post date:** [April 3, 2020, 5:34am UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/6 "2020-04-03T05:34:08Z")

</div>

Going to the Meta file and changing it there on the itemType field was a fix for that.

---

<div class="post-metadata">

**Author:** ![Levi\_Barrocas](https://forum.radzen.com/user_avatar/forum.radzen.com/levi_barrocas/32/1287_2.png) [@Levi\_Barrocas](https://forum.radzen.com/u/Levi_Barrocas)\
**Post date:** [April 8, 2020, 1:33am UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/7 "2020-04-08T01:33:25Z")

</div>

Going to bump this as I updated to the newest version that came out yesterday and this issue remains

---

<div class="post-metadata">

**Author:** ![Levi\_Barrocas](https://forum.radzen.com/user_avatar/forum.radzen.com/levi_barrocas/32/1287_2.png) [@Levi\_Barrocas](https://forum.radzen.com/u/Levi_Barrocas)\
**Post date:** [April 8, 2020, 4:34pm UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/8 "2020-04-08T16:34:49Z")

</div>

The issue remains here even after changing to 2.44.11

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [April 8, 2020, 4:40pm UTC](https://forum.radzen.com/t/problem-in-blazor-datagrid-with-custom-classes/3124/9 "2020-04-08T16:40:48Z")

</div>

Unfortunately we can't reproduce it after the latest fix. You can try recreating the DataGrid or setting TItem as an attribute.
