asp.net - SelectMethod in objectDatasource getting called multiple times with multiple datapagerfield -


ok, here setup. building page has listview, datapager, , 3 datapagerfield (2 x nextpreviouspagerfield, 1 x numericpagerfield), , objectdatasource tide of together.

it working fine until put breakpoint selectmethod specified in objectdatsource control. seems each datapagerfield control, calling selectmethod , selectcount method. hence, whenever user paged, calls database 6 times instead of 2 (i don't have caching turned on atm). if remove 1 datapagerfield, remove 2 calls.

now build in asp.net 3.5 sp1 in vs2008. when copied same code files asp.net 4.0 vs2010 solution, duplicate call seems gone.

is bug in asp.net 3.5 sp1?

thanks in advance

actually should using onselecting event.

what happens objectdatasource calls method selectmethod twice

  1. first time gets data.
  2. next time gets count.

so think have implement onselecting event

<asp:objectdatasource id="ods" runat="server" selectmethod="getlist" selectcountmethod="getlistcount"      onselecting="ods_selecting">     typename="website.test" enablepaging="true" />  

and cancel event when objectdatasource tries call count method.

 protected void ods_selecting(object sender,                 objectdatasourceselectingeventargs e)  {       if (e.executingselectcount)       {            //cancel event               return;       } } 

you can use link below db call not made fetch count. http://www.unboxedsolutions.com/sean/archive/2005/12/28/818.aspx

hope helps.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -