.NET-Noob and Databinding (DataSet, DetailsView)

M

Martin Frey

Hello guys,
im new to asp.net and im trying to get me used to it. I've managed to create
webpages with detailviews, databinding and datasources. Adding or inserting
data went very well and, after a while, very fast.

Now i ran into a problem with accessing the data. I need to send an email to
the administrator with the data the user has selected instead of calling the
update method. Everything i've build up via the designer or the wizards.
Created a DataTable with a TableAdapter within a DataSet.xsd and a
DetailsView which is bound via an ObjectDataSource to the TableAdapter.
To send the email i've added a commandbutton to the detailsview and use the
clickeventmethod. But i was not able to get the data in a "clean" way. I
thought the DataTable would be my businessobject, but i have not managed to
access this data via an attribute or method or whatever. At the moment i
solved it with accessing the Controls within the DetailsView directly and
getting f.e. the Text attribute from the TextBoxes. But i have the feeling
that it should be alot easier..? Shouldnt i be able to read the data i need
from a businessobject instead? But i was not able to find a method or field
within the DetailsView or DataSource to get access to such a businessobject.

Would be nice to get some help here.


Thanks alot
Martin
 
M

Martin Frey

I've crawled the "complete" Google now and all solutions i've found were by
accessing the controls directly... Like DetailsView1.FindControl("modules")
and so on. Is this really the way to go?

Comming from the Java world i'd expected a dataobject that i can use in the
backingclass to access the data. The DataTable seems the correct one. But
since i use the DataSource binding i was not able to find a field that
directs me to the current datatable of the detailsview or the assigned
tableadapter.
I'm able to create a DataTable by myself and also filling this one through
the tableadapter. But this is completely new data and not the one the user
entered.

I now have another idea but im not sure if this is working. Within the
pageload method i can create and fill a datatable with the tableadapter. Am
i able to bind the detailsview on this datatable instead of the datasource?
I'd say for this solution i need to disable "AutoBinding" somehow. Is this
possible somehow?

Thanks
Martin
 
M

Mark Rae [MVP]

At the moment I solved it with accessing the Controls within the
DetailsView directly and getting e.g. the Text attribute from the
TextBoxes.

Yep, that's certainly how I'd do it...
But I have the feeling that it should be alot easier..?

How much easier would you like it to be...?
Would be nice to get some help here.

Sounds like you're on the right track...
 
A

Alvin Bruney [MVP]

Why don't you manually bind your details view to a dataset, skipping the
datasource. that will give you more control over the underlying data.
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top