DetailsView ObjectDataSource, and DataSet: Confused

Discussion in 'ASP .Net Web Controls' started by noah.blumenthal@gmail.com, Jun 18, 2007.

  1. Guest

    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
     
    , Jun 18, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmltIEhhbW1vbmQ=?=

    DetailsView and ObjectDataSource - how to get updated object

    =?Utf-8?B?SmltIEhhbW1vbmQ=?=, Oct 4, 2005, in forum: ASP .Net
    Replies:
    12
    Views:
    8,569
    =?Utf-8?B?SmltIEhhbW1vbmQ=?=
    Oct 18, 2005
  2. Spotnick
    Replies:
    0
    Views:
    1,586
    Spotnick
    Jan 21, 2006
  3. J055
    Replies:
    1
    Views:
    1,932
    Steven Cheng[MSFT]
    Apr 5, 2006
  4. =?Utf-8?B?RGVuaXMgU29oZXQ=?=

    Error with ObjectDataSource and DetailsView - conversion error

    =?Utf-8?B?RGVuaXMgU29oZXQ=?=, Mar 28, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    451
    =?Utf-8?B?RGVuaXMgU29oZXQ=?=
    Mar 28, 2007
  5. Bill Gower

    DetailsView and ObjectDataSource

    Bill Gower, Aug 30, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    387
    Bill Gower
    Aug 30, 2007
Loading...

Share This Page