user1137472
user1137472

Reputation: 345

Count not functioning to needs

I have the following code: @String.Format("Total of {0} results", Model.Count())

But it is only adding up the first page results I have paging on my index.cshtml and the count only takes in to account the first page how would this be fixed so it can take in all pages of the results on the Index.

Upvotes: 1

Views: 94

Answers (1)

Paweł Staniec
Paweł Staniec

Reputation: 3181

If your controller returns only a part of the results to satisfy your paging mechanism, then you need to either use a ViewModel that will contain records collection and a property holding number of all records, or you need to setup additional action on your controller that will provide that number. Then you will retrieve it dynamically with jQuery for example.

It's hard to say what will solve your problem, as you didn't provide the code or details about what kind of paging you're using, if you utilize webgrid or something else.

Upvotes: 1

Related Questions