473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ASP.NET 2.0 SelectCountMethod

I noticed that the SelectCountMethod is called on every postback to the
server when navigating the pages in a GridView. Do you know why this is?

This is a performance problem since I have to do a query and then have to do
some manipulation on the entire results to figure out the count (No it isn't
possile to do it from SQL). I'm thinking I have to stash the count in my
ObjectDataSource so that I can just hand it back on a post back since it
never changes from page to page (page in the sense of paging in the
gridview). The thing is I now have to let the class bound to the
objectDatasource control know when it is a postback so I can return a cached
value instead of a recalculating it.

Is there a better way of doing this instead of linking my data object layer
to what is happening in the UI?

Thanks,

Chris

Nov 19 '05 #1
6 3913
With the ObjectDataSource and your data access class, it's entirely up to
you how to implement those semenatics. If you want your SelectCountMethod
to go back to the DB every time, then fine. But if it's too expensive then
you can implement it to cache that data.

As for the reason it's called every time, this is simply to adjust to any
updates to the DB since the last time the page was accessed. This has to
be done since it's possible to have seen a row on the last page, say, then
switch pages the come back to the last page and then the row is missing,
presumably because more rows were inserted prior to that last row. (Gosh,
I hope that made sense).

-Brock
DevelopMentor
http://staff.develop.com/ballen
I noticed that the SelectCountMethod is called on every postback to
the server when navigating the pages in a GridView. Do you know why
this is?

This is a performance problem since I have to do a query and then have
to do some manipulation on the entire results to figure out the count
(No it isn't possile to do it from SQL). I'm thinking I have to stash
the count in my ObjectDataSource so that I can just hand it back on a
post back since it never changes from page to page (page in the sense
of paging in the gridview). The thing is I now have to let the class
bound to the objectDatasource control know when it is a postback so I
can return a cached value instead of a recalculating it.

Is there a better way of doing this instead of linking my data object
layer to what is happening in the UI?

Thanks,

Chris

Nov 19 '05 #2
Oldman,

Try setting EnableCaching="True" in your Object Data Source. This worked for
me in a quick little test.

The ODS is pretty efficient with it queries assuming your underlying data
access is efficient.

-Andrew
"Oldman" <Ol****@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
I noticed that the SelectCountMethod is called on every postback to the
server when navigating the pages in a GridView. Do you know why this is?

This is a performance problem since I have to do a query and then have to
do
some manipulation on the entire results to figure out the count (No it
isn't
possile to do it from SQL). I'm thinking I have to stash the count in my
ObjectDataSource so that I can just hand it back on a post back since it
never changes from page to page (page in the sense of paging in the
gridview). The thing is I now have to let the class bound to the
objectDatasource control know when it is a postback so I can return a
cached
value instead of a recalculating it.

Is there a better way of doing this instead of linking my data object
layer
to what is happening in the UI?

Thanks,

Chris

Nov 19 '05 #3
Good point on updates.
I'm a little confused though how to cache the data from within the data
access class. You don't have access to the Page's cache, unless you pass it
in or set it (is that the only way?) and if you put it in a static variable
then all threads will share it and that won't work.

Thanks for you response though. That cleared up why it is called each time.

"Brock Allen" wrote:
With the ObjectDataSource and your data access class, it's entirely up to
you how to implement those semenatics. If you want your SelectCountMethod
to go back to the DB every time, then fine. But if it's too expensive then
you can implement it to cache that data.

As for the reason it's called every time, this is simply to adjust to any
updates to the DB since the last time the page was accessed. This has to
be done since it's possible to have seen a row on the last page, say, then
switch pages the come back to the last page and then the row is missing,
presumably because more rows were inserted prior to that last row. (Gosh,
I hope that made sense).

-Brock
DevelopMentor
http://staff.develop.com/ballen
I noticed that the SelectCountMethod is called on every postback to
the server when navigating the pages in a GridView. Do you know why
this is?

This is a performance problem since I have to do a query and then have
to do some manipulation on the entire results to figure out the count
(No it isn't possile to do it from SQL). I'm thinking I have to stash
the count in my ObjectDataSource so that I can just hand it back on a
post back since it never changes from page to page (page in the sense
of paging in the gridview). The thing is I now have to let the class
bound to the objectDatasource control know when it is a postback so I
can return a cached value instead of a recalculating it.

Is there a better way of doing this instead of linking my data object
layer to what is happening in the UI?

Thanks,

Chris


Nov 19 '05 #4
Thanks for your response.
I don't think I can enable caching. If I do won't it use the same results
each time.
My data access object only returns the results for the current page being
shown. I need to get a new set of records for the next page when the user
clicks to see the next page.

Thanks,

Chris (Oldman)

"Andrew Robinson" wrote:
Oldman,

Try setting EnableCaching="True" in your Object Data Source. This worked for
me in a quick little test.

The ODS is pretty efficient with it queries assuming your underlying data
access is efficient.

-Andrew
"Oldman" <Ol****@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
I noticed that the SelectCountMethod is called on every postback to the
server when navigating the pages in a GridView. Do you know why this is?

This is a performance problem since I have to do a query and then have to
do
some manipulation on the entire results to figure out the count (No it
isn't
possile to do it from SQL). I'm thinking I have to stash the count in my
ObjectDataSource so that I can just hand it back on a post back since it
never changes from page to page (page in the sense of paging in the
gridview). The thing is I now have to let the class bound to the
objectDatasource control know when it is a postback so I can return a
cached
value instead of a recalculating it.

Is there a better way of doing this instead of linking my data object
layer
to what is happening in the UI?

Thanks,

Chris


Nov 19 '05 #5
HttpContext.Current.Cache or build your own.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Good point on updates.
I'm a little confused though how to cache the data from within the
data
access class. You don't have access to the Page's cache, unless you
pass it
in or set it (is that the only way?) and if you put it in a static
variable
then all threads will share it and that won't work.
Thanks for you response though. That cleared up why it is called each
time.

"Brock Allen" wrote:
With the ObjectDataSource and your data access class, it's entirely
up to you how to implement those semenatics. If you want your
SelectCountMethod to go back to the DB every time, then fine. But if
it's too expensive then you can implement it to cache that data.

As for the reason it's called every time, this is simply to adjust to
any updates to the DB since the last time the page was accessed. This
has to be done since it's possible to have seen a row on the last
page, say, then switch pages the come back to the last page and then
the row is missing, presumably because more rows were inserted prior
to that last row. (Gosh, I hope that made sense).

-Brock
DevelopMentor
http://staff.develop.com/ballen
I noticed that the SelectCountMethod is called on every postback to
the server when navigating the pages in a GridView. Do you know why
this is?

This is a performance problem since I have to do a query and then
have to do some manipulation on the entire results to figure out the
count (No it isn't possile to do it from SQL). I'm thinking I have
to stash the count in my ObjectDataSource so that I can just hand it
back on a post back since it never changes from page to page (page
in the sense of paging in the gridview). The thing is I now have to
let the class bound to the objectDatasource control know when it is
a postback so I can return a cached value instead of a recalculating
it.

Is there a better way of doing this instead of linking my data
object layer to what is happening in the UI?

Thanks,

Chris

Nov 19 '05 #6
Duh. I knew there must be a general way of getting it.

Thanks!

"Brock Allen" wrote:
HttpContext.Current.Cache or build your own.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Good point on updates.
I'm a little confused though how to cache the data from within the
data
access class. You don't have access to the Page's cache, unless you
pass it
in or set it (is that the only way?) and if you put it in a static
variable
then all threads will share it and that won't work.
Thanks for you response though. That cleared up why it is called each
time.

"Brock Allen" wrote:
With the ObjectDataSource and your data access class, it's entirely
up to you how to implement those semenatics. If you want your
SelectCountMethod to go back to the DB every time, then fine. But if
it's too expensive then you can implement it to cache that data.

As for the reason it's called every time, this is simply to adjust to
any updates to the DB since the last time the page was accessed. This
has to be done since it's possible to have seen a row on the last
page, say, then switch pages the come back to the last page and then
the row is missing, presumably because more rows were inserted prior
to that last row. (Gosh, I hope that made sense).

-Brock
DevelopMentor
http://staff.develop.com/ballen
I noticed that the SelectCountMethod is called on every postback to
the server when navigating the pages in a GridView. Do you know why
this is?

This is a performance problem since I have to do a query and then
have to do some manipulation on the entire results to figure out the
count (No it isn't possile to do it from SQL). I'm thinking I have
to stash the count in my ObjectDataSource so that I can just hand it
back on a post back since it never changes from page to page (page
in the sense of paging in the gridview). The thing is I now have to
let the class bound to the objectDatasource control know when it is
a postback so I can return a cached value instead of a recalculating
it.

Is there a better way of doing this instead of linking my data
object layer to what is happening in the UI?

Thanks,

Chris


Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: csockwell | last post by:
I love the objectdatasource conrtol but I'm having trouble using the paging controls. I'm trying to create a user control to which I can bind a objectdatasource control. I've been successful at...
0
by: csockwell | last post by:
I'm having trouble using the paging controls. I'm trying to create a user control to which I can bind a objectdatasource control. I've been successful at binding to a repeater and I would like...
0
by: ber.janssens | last post by:
Hi, I am trying the new ObjectDataSource from ASP.NET 2.0. I connected a Gridview with ObjectDataSource which is connected to a webservice which returns a DataSet. In the Webmethod I return...
7
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I...
6
by: miky | last post by:
Hi, I'm trying to get custom gridview paging working and I'm getting the following error: "ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'count' that has parameters:...
0
by: ssims | last post by:
I've got a GridView that's sorted by a stored procedure with ROW_NUMBER: PROCEDURE dbo.GetCalendarsByStatusIDPaged ( @startRowIndex int, @maximumRows int, @statusID int ) AS
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
7
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
The default paging behavior of the gridview doesn't work well with very large sets of data which means we have to implement some sort of custom paging. The examples I have seen (4guysfromrolla,...
0
by: Question123 | last post by:
Hello.. i want to pass 3 parameters for SelectMethod and 1 parameters for SelectCountMethod of ObjectDataSource. How can i pass these?? And how ObjectDataSource can distinguish which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.