# Count issue

**URL:** <https://forum.radzen.com/t/count-issue/6260>\
**Category:** Angular\
**Created:** [January 11, 2021, 3:22pm UTC](https://forum.radzen.com/t/count-issue/6260 "2021-01-11T15:22:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FredK\_Trashmail](https://forum.radzen.com/user_avatar/forum.radzen.com/fredk_trashmail/32/2226_2.png) [@FredK\_Trashmail](https://forum.radzen.com/u/FredK_Trashmail)\
**Post date:** [January 11, 2021, 3:22pm UTC](https://forum.radzen.com/t/count-issue/6260/1 "2021-01-11T15:22:14Z")

</div>

Hi again,

Using MSSQL, I am trying to auto-generate the new ID for any record addition.  
Using CRUD, I have generated the Add page which is fine. I have added a numeric field which returns the count of a related field in a different table (dropdown) and it works fine. That count is the one automatically generated for the paging of the dropdown. I get to see the correct value (using here ${getStatusesForStatusCount}).

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

If I do exactly the same to get a count of existing IDs in the table I want to add, numeric field remains empty.

 ![image](https://forum.radzen.com/uploads/default/original/2X/4/439520554ce387d8bbfb0bfc3fe39870bbb5cffe.png)

Grateful if you could let me know what I do wrong.

Thank you

Fred

---

<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:** [January 11, 2021, 3:56pm UTC](https://forum.radzen.com/t/count-issue/6260/2 "2021-01-11T15:56:59Z")

</div>

Hi @FredK_Trashmail,

In my opinion it will be better if your primary key is identity - in this case everything will automatic:

> **[IDENTITY (Property) (Transact-SQL) - SQL Server](https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property?view=sql-server-ver15)**
>
> CREATE TABLE (Transact-SQL) IDENTITY (Property)

---

<div class="post-metadata">

**Author:** ![FredK\_Trashmail](https://forum.radzen.com/user_avatar/forum.radzen.com/fredk_trashmail/32/2226_2.png) [@FredK\_Trashmail](https://forum.radzen.com/u/FredK_Trashmail)\
**Post date:** [January 11, 2021, 4:19pm UTC](https://forum.radzen.com/t/count-issue/6260/3 "2021-01-11T16:19:29Z")

</div>

Ah! I started all this because I didn't figure out how to ensure auto-increment., id being the primary.

If I follow your suggestion, I just need to remove the Id field (or make it read-only) and I am good to go ?

---

<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:** [January 11, 2021, 4:23pm UTC](https://forum.radzen.com/t/count-issue/6260/4 "2021-01-11T16:23:46Z")

</div>

Yep, you can remove the primary key field from the form in this case.

---

<div class="post-metadata">

**Author:** ![FredK\_Trashmail](https://forum.radzen.com/user_avatar/forum.radzen.com/fredk_trashmail/32/2226_2.png) [@FredK\_Trashmail](https://forum.radzen.com/u/FredK_Trashmail)\
**Post date:** [January 11, 2021, 4:24pm UTC](https://forum.radzen.com/t/count-issue/6260/5 "2021-01-11T16:24:41Z")

</div>

Great. Saves work. Thank you. Yet still don't understand why I couldn't get the Count

---

<div class="post-metadata">

**Author:** ![FredK\_Trashmail](https://forum.radzen.com/user_avatar/forum.radzen.com/fredk_trashmail/32/2226_2.png) [@FredK\_Trashmail](https://forum.radzen.com/u/FredK_Trashmail)\
**Post date:** [January 11, 2021, 6:22pm UTC](https://forum.radzen.com/t/count-issue/6260/6 "2021-01-11T18:22:07Z")

</div>

Turns out I can't save, even when removing the id field.

So back to the initial idea but will do it in Blazor. Easier for me

---

<div class="post-metadata">

**Author:** ![mumfie](https://forum.radzen.com/letter_avatar_proxy/v4/letter/m/b4bc9f/32.png) [@mumfie](https://forum.radzen.com/u/mumfie)\
**Post date:** [January 11, 2021, 9:45pm UTC](https://forum.radzen.com/t/count-issue/6260/7 "2021-01-11T21:45:35Z")

</div>

@FredK_Trashmail  
Should just work if you added the identity column to the database. Did you refresh the data via _data, Infer Schema_ ensuring the ID is selected after updating the database?

---

<div class="post-metadata">

**Author:** ![FredK\_Trashmail](https://forum.radzen.com/user_avatar/forum.radzen.com/fredk_trashmail/32/2226_2.png) [@FredK\_Trashmail](https://forum.radzen.com/u/FredK_Trashmail)\
**Post date:** [January 11, 2021, 9:48pm UTC](https://forum.radzen.com/t/count-issue/6260/8 "2021-01-11T21:48:59Z")

</div>

Being a beginner under time constrain and not too advanced, I started again with Blazor where finding my way around is easier. Almost done by the way. I just pass the count+1 as a parmeter from the page to the dialog which encapsulates the Add Page.

Anyway, thank you very much for your reply.

Cheers
