Couple of questions about DetailsView and ObjectDataSource controls

J

J055

Hi

I have a Business class called User which returns a DataRow for individual
user accounts using accountID as a parameter (i.e.
User.Retrieve(accountID)). The ObjectDataSource doesn't complain if I attach
the method to the SelectMethod property but the DetailsView does not display
it properly. The returned data in the DataRow is correct.

Do I need to put the DataRow back in a DataTable first or is there another
way? Also, if my class returns a user account through public properties can
I use the ObjectDataSource?

Can someone give me some pointers? I've already read most of the msdn stuff
but most of it seems to use the SqlDataSource as an example with the
DetailsView. So anything which deals with the DetailsView and
ObjectDataSource together would be useful.

Many thanks
Andrew
 
S

Steven Cheng[MSFT]

Hi Andrew,

Thank you for posting.

As for the DataRow databinding problem, based on my understanding, it is
because ASP.NET databinding (bound a control's certain property to a
datafield of another dataobject) is based on class's "Property", not
field. And when we bind a DataSet or DataTable to a databound control(e.g a
DataGrid or GridView...), the databound control finally get a DataView
object, and the data object bound to each RowItem in the control is not
DataRow, instead it is a DataRowView. The difference between DataRow and
DataRowView is that DataRow does not expose Data fields (columns) through
public property or can not be reflected through PropertyDescriptor... While
the DataRowview class can let the databound control dynamically reflect its
data properties... (e.g through DataBinder.Eval(....)).

Though DataRowView can be used by databound control, I do not recommend
your data access class return this class's instance since it is mainly used
by ADO.NET built-in data components. For your scenario, I'd rather suggest
you create your own custom Account class which expose those data
fields(columns) through public properties, this can help them be correctly
reflected by databound control.

Hope this helps. If there's anything else unclear, please feel free to post
here.

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top