Re: ASP.NET binding to DataReader



Hi Mark,

I think maybe Andrew also want to utilize the declarative/codeless
databinding model of ASP.NET 2.0 to populate the controls with records
retrieved through datareader.

Hi Anderw,

I also think that using an objectDataSource here is not quite confortable
and convenient. Because if you use DataReader, your business object query
the DB and return datareader, the close/disposing code should also be
performed by the buisness object. However, during the databinding period,
the objectdatasource will use the datareader to perform databinding against
the target databound control. Thus, your business class has to determine
when to close/dispose the datareader(this is the question here...). Or you
can let the ObjectDatasource to close the DataReader(expose from your
business object through some public interface/methods).

So far, I think you can consider use the following event of
objectdatasource control:

#ObjectDataSource.ObjectDisposing Event
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdat
asource.objectdisposing.aspx

it can let you do some work before the ObjectDataSource disposing the
underlying business class object. You can get the assocated DataReader from
the object instance and close it at that time. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.





--------------------
From: "Mark Rae [MVP]" <mark@xxxxxxxxxxxxxxxxx>
References: <Ot62W0m5HHA.5980@xxxxxxxxxxxxxxxxxxxx>
<OjMl28m5HHA.980@xxxxxxxxxxxxxxxxxxxx>
<eH8Eu#m5HHA.5844@xxxxxxxxxxxxxxxxxxxx>
In-Reply-To: <eH8Eu#m5HHA.5844@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: ASP.NET binding to DataReader
Date: Fri, 24 Aug 2007 21:23:16 +0100
Lines: 14
Organization: http://www.markrae.net
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=response
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16480
Message-ID: <#O38ryo5HHA.1164@xxxxxxxxxxxxxxxxxxxx>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 82-45-166-9.cable.ubr06.hari.blueyonder.co.uk
82.45.166.9
Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:39736
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

"Andrew Robinson" <nemoby@xxxxxxxxxxxxx> wrote in message
news:eH8Eu%23m5HHA.5844@xxxxxxxxxxxxxxxxxxxxxxx

isn't that the purpose of an ODS? to link your data access layer to
server
data controls?

If you have a DAL, the data controls are completely unnecessary...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net



.



Relevant Pages

  • RE: Display a record - several questions
    ... ObjectDataSource set up to get the correct record on a select. ... sub controls in the certain tepmlate and modify them. ... How do I display a RadioButtonList and CheckBox value where it is ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: What I saw at MS Launch
    ... In regards to .NET and data binding, Eco and Bdp provide a greater level of abstraction. ... So you bind a DataSource of a specific type to the controls. ... Let's say you bind your controls to SqlDataSource. ... Now you have to change all references of SqlDataSource to ObjectDataSource and change the control bindings. ...
    (borland.public.delphi.non-technical)
  • Re: How to clear controls from a form - Help Needed
    ... You could load a datatable from the datareader and return the datatable. ... Dim DR as SQLDataReader=nothing ... a copy of the datareader back to the caller and dispose the one in the body ... (but can be used in objects that controls are using). ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Enable controls dynamically
    ... it when looping the results). ... you probably need to have controls in some sort of array or list ... where you would set others (not included in the datareader so set their ... > item "txtFirstName" then txtFirstName should be visible. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: formview with objectDataSource wont display data
    ... the paging on the FormView. ... DataReader, the ObjectDataSource on the other hand, as the stated in the ... SqlDataReader object), because this same instance of the object will be used ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)