# Error CS0266: Cannot implicitly convert type 'int?' to 'int'

**URL:** <https://forum.radzen.com/t/error-cs0266-cannot-implicitly-convert-type-int-to-int/8658>\
**Category:** Blazor Server\
**Created:** [August 6, 2021, 6:48pm UTC](https://forum.radzen.com/t/error-cs0266-cannot-implicitly-convert-type-int-to-int/8658 "2021-08-06T18:48:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kest874](https://forum.radzen.com/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@kest874](https://forum.radzen.com/u/kest874)\
**Post date:** [August 6, 2021, 6:48pm UTC](https://forum.radzen.com/t/error-cs0266-cannot-implicitly-convert-type-int-to-int/8658/1 "2021-08-06T18:48:54Z")

</div>

I'm sure I'm missing something simple.

I'm looking to set a property based on a database value:

 ![image](https://forum.radzen.com/uploads/default/original/2X/b/b717f4ac81a4eae0b2477f60dd0169cb982c0cb2.png)

LocationID will be used to filter the grid. I'm getting "error CS0266: Cannot implicitly convert type 'int?' to 'int'"

The Location ID is of type int.

If I create a label with ${CurrentUser.FirstOrDefault()?.LocationID} as the value I do see the LocationID.

Any ideas?

---

<div class="post-metadata">

**Author:** ![kest874](https://forum.radzen.com/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@kest874](https://forum.radzen.com/u/kest874)\
**Post date:** [August 6, 2021, 7:05pm UTC](https://forum.radzen.com/t/error-cs0266-cannot-implicitly-convert-type-int-to-int/8658/2 "2021-08-06T19:05:19Z")

</div>

> [@kest874](#):
>
> I'm sure I'm missing something simple.

Yep.. ${CurrentUser.FirstOrDefault().LocationID} removal of the ?

---

<div class="post-metadata">

**Author:** ![SloSuenos](https://forum.radzen.com/user_avatar/forum.radzen.com/slosuenos/32/9256_2.png) [@SloSuenos](https://forum.radzen.com/u/SloSuenos)\
**Post date:** [August 6, 2021, 11:53pm UTC](https://forum.radzen.com/t/error-cs0266-cannot-implicitly-convert-type-int-to-int/8658/3 "2021-08-06T23:53:05Z")

</div>

Look at the LocationID field in your database, are you allowing null values? Based on that either remove the "?" from your value statement, or change the property type to "int?"

They have to match.
