|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get cached value returned from Select()Hi;
In my code-behind, is there a way to get the data returned from the Select() call from an ObjectDataSource? I know I can call it again, but when the page is first created ASP has already called it to populate controls and I would prefer to not call it twice. Also, is there a way to find out if the last call to Select() actually returned a row of data? In other words, if the page is displaying <EmptyDataTemplate> I would like to know that in my code-behind. Hi Dave,
Thank you for posting. As for ObjectDataSource control, we can use the Selected Event to get the Data Object returned by its internall Select operation. This event fire after the internal data access class instance has selected and returned the data object(e.g DataSet or DataTable...). e.g: ==================== protected void ObjectDataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs e) { Response.Write("<br/>" + e.ReturnValue.GetType()); } ======================== #ObjectDataSource.Selected Event http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat asource.selected(VS.80).aspx Also, if the data access object use instance method as Select method, the runtime will create an instance of the Data Access class, thus, we can access that Data Access class's instance through the "ObjectCreated" event, then if have defined some internal property and method on the Data Access class for cache and get the cached data object, we can access it through the object obtained in the "ObjectCreated" event: protected void ObjectDataSource1_ObjectCreated(object sender, ObjectDataSourceEventArgs e) { Response.Write("<br/>" + e.ObjectInstance.GetType()); } #ObjectDataSource.ObjectCreated Event http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat asource.objectcreated(VS.80).aspx Hope this helps. Regards, Steven Cheng Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) perfect - thanks - dave
Show quoteHide quote "Steven Cheng[MSFT]" wrote: > Hi Dave, > > Thank you for posting. > > As for ObjectDataSource control, we can use the Selected Event to get the > Data Object returned by its internall Select operation. This event fire > after the internal data access class instance has selected and returned the > data object(e.g DataSet or DataTable...). e.g: > > ==================== > protected void ObjectDataSource1_Selected(object sender, > ObjectDataSourceStatusEventArgs e) > { > Response.Write("<br/>" + e.ReturnValue.GetType()); > } > ======================== > > #ObjectDataSource.Selected Event > http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat > asource.selected(VS.80).aspx > > > Also, if the data access object use instance method as Select method, the > runtime will create an instance of the Data Access class, thus, we can > access that Data Access class's instance through the "ObjectCreated" event, > then if have defined some internal property and method on the Data Access > class for cache and get the cached data object, we can access it through > the object obtained in the "ObjectCreated" event: > > protected void ObjectDataSource1_ObjectCreated(object sender, > ObjectDataSourceEventArgs e) > { > > Response.Write("<br/>" + e.ObjectInstance.GetType()); > } > > > #ObjectDataSource.ObjectCreated Event > http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat > asource.objectcreated(VS.80).aspx > > > Hope this helps. > > Regards, > > Steven Cheng > Microsoft Online Community Support > > > ================================================== > > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > > ================================================== > > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > Get Secure! www.microsoft.com/security > (This posting is provided "AS IS", with no warranties, and confers no > rights.) > > You're welcome Dave,
Best Regards, Steven Cheng Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
DataSourceControl and declarative SelectParameters
FileSystemWatcher does not seem to be working Javascript with Webcontrols MyGridView cause "Columes" lose the intellisense in VS2005 IDE! Print version use CSS or similar ? Sorting Datagrid 2.0 TreeNode How to get dynamic control's value after postback? SmartNavigation/MaintainScrollPositionOnPostback & Datagrids Edit, Update, Cancel |
|||||||||||||||||||||||