[thelist] asp datagrid frustration

David Travis dwork at macam.ac.il
Thu Sep 23 08:26:02 CDT 2004


The proper way to do it is like this: in page load method if not postback
bind the grid with default sort expression. Create a sorting handler which
will bind the grid with the clicked expression. This way the "page load"'s
binding executes only when it is first time the page loads, and all
subsequent resorts fire the binding process with the sorting expression.


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Greg Holmes
Sent: Thursday, September 23, 2004 11:55 AM
To: thelist at lists.evolt.org
Subject: Re: [thelist] asp datagrid frustration

Mark Aldrich wrote:

>I have a search that is fired by an if
>'IsPostBack' test in the apps 'page load'
>sub. All well and good a reader object is
>bound to the grid with my data.

Can't tell for sure from the way you wrote
this, but typically the initial query would
be triggered by it NOT being a postback,
thus being the initial page load.

>The problem occurs when i sort a column. i
>have a sortcolumn handler which functions
>perfectly - i.e a requery of the database
>with a different sort expression. this is
>called when a hyperlink in the datagrid
>header is clicked. Unfortunately it goes
>through the page load sub again and of course
>it is a postback so before it calls the sort
> column sub, it automatically performs the
>same query again!!
>idealy clicking on the header would result
>in the ispostback test returning false or
>.somesuch logic. I know i could rewrite it
>in javascript  hehe but that wont be hapenin.

It almost sounds like you have it backward.
Do the inital query when it is NOT a postback.
Do modified queries when it IS a postback.

Greg Holmes

* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 

More information about the thelist mailing list