Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Controls / April 2006

Tip: Looking for answers? Try searching our database.

Get cached value returned from Select()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 22 Apr 2006 18:23 GMT
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.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Steven Cheng[MSFT] - 24 Apr 2006 09:42 GMT
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.

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

David Thielen - 24 Apr 2006 18:27 GMT
perfect - thanks - dave

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

> Hi Dave,
>
[quoted text clipped - 54 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Steven Cheng[MSFT] - 25 Apr 2006 01:56 GMT
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.

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.