Avatar of perksdev
perksdev

asked on 

GridView doesn't refresh paging when ObjectDataSource returns empty collection.

I have an ASP.Net 3.5 web page with a GridView that's bound to an ObjectDataSource.  Paging and sorting have been enabled and everything works fine when the DataSource returns data.  In certain instances when the DataSource returns null or an Empty collection, the GridView retains the paging from the previous Select instead of hiding the GridView due to an empty result set.

I have a parameter being passed to the ObjectDataSource that can be used to filter the results.  When this parameter causes the DataSource to return null or an Empty collection, the paging doesn't reset.  I have checked that the Select Method used by the ODS is actually returning and empty collection (List<>) and that the Count Method used by the ODS is returning zero.

If I click the search button a second time, the GridView becomes hidden as I would have expected it to do the first time.

If I need to give more information I would be happy to, but that I think that sums up the problem for now.

Any help is greatly appreciated.  Thanks.
.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
perksdev
Avatar of Bembi
Bembi
Flag of Germany image

Not quite sure about the internal of this GridView, but if the recordset is empty, nothing is delivered to the Grid and it may be  that the gridview does't initiate a refresh. I has similar things with several gridview controls.

Whats about (as you said you have a button for searching) to refresh the gridview after the user has pressed the button, or to check the result before and then clear the grid if the result is empty.  
ASKER CERTIFIED SOLUTION
Avatar of funwithdotnet
funwithdotnet

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of perksdev
perksdev

ASKER

While I still would have liked to get the GridView working properly (showing EmptyData Template/Text), this workaround is what I ended up going with.

Thanks.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo