DetailsView ObjectDataSource, and DataSet: Confused

N

noah.blumenthal

I am new to asp.net and am learning the concepts and terminology as I
go, so please excuse me if I'm really off base here...

I am trying to add a DetailsView control to a page and have read up on
it and it sure looks easy in all the tutorials I read. However, I do
not wish to use textual SQL statements for my selects/updates/deletes
as the tutorials I have read describe. I already have a DataSet in my
project that has definitions for all my tables and would like to use
that as the datasource for my DetailsView control.

So here's what steps I take. In Design Mode in VS.NET2003, I select
the data source for the DetailsView control. I select "New Data
Source" and then choose and "Object" data source. I select the
DataSet1TableAdapters.userTableAdapter (I'm creating a user edit page
for admins to edit user information) and continue.

Now is where I start having problems. Now under the Update and Delete
tabs there are no methods for me to select. I did some research and
found that I can create methods for updating and deleting data in the
DataSet by visiting the DataSet's TableAdapters properties and so I
did that; I created a stored procedure that I can use to update data,
and then I selected that stored procedure as the UpdateCommand in the
properties of the DataSet's TableAdapters. Then I was given that
UpdateUser(Int32 id, String username, String password, [...]) as an
option under the Update tab of that Configure Data Source window.

I will be using a DataGrid for the admin to select the user to edit
and then the DetailsView will only show that user's info, so I have
set the DefaultMode of the DetailsView to Edit. Now when I run the
site I actually see data in the DetailsView but when I edit it and
press "Update", there is a postback and the original data reappears.
I tried debugging by assigning a method to run on ItemUpdating that
would loop through the new values. Well I did just that:

void DetailsView1_ItemUpdating(object sender,
DetailsViewUpdateEventArgs e)
{
string value;
for (int i = 0; i < e.NewValues.Count ; i++)
{
value = e.NewValues.ToString();
}
}

and put a breakpoint at the entrance but when I clicked Update on the
web form and I stepped through the code, that "value" variable I have
always contained the _old_ values, not the newly entered ones.

So this is sort of an all around question because I don't know if I'm
doing this all wrong or if I'm just missing something. I'm leaning
towards the former because another issue I can't seem to answer is how
to pull up a specific record via the DetailsView (currently it always
just pulls up the first row of the table, but obviously I will want to
pull up a specific row to edit).

I've been searching google and trying all kinds of things for hours
and hours. If someone could point me in the right direction I'd
really appreciate it!

Thanks,
Noah
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top