Home All Groups Group Topic Archive Search About

Get cached value returned from Select()

Author
22 Apr 2006 5:23 PM
David Thielen
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.

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

Author
24 Apr 2006 8:42 AM
Steven Cheng[MSFT]
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.)
Author
24 Apr 2006 5:27 PM
David Thielen
perfect - thanks - dave

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



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.)
>
>
Author
25 Apr 2006 12:56 AM
Steven Cheng[MSFT]
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.)