updating a typed dataset (newbie question?)

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default updating a typed dataset (newbie question?)

    I created a DataGrid and bound a DataView of a typed DataSet to it (i tried
    with the DataSet as well but i'd rather use the DataView as i'm using it for
    sorting). I have paging working, sorting and the edit template is cool. When
    i hit Update i wonder what i have to do to update the database with the user
    inputted values.

    Now in a perfect world the datagrid, bound to my view would have a method
    for updating the selected row of the dataset/view with the templated values.
    All i had to do is call myDataAdapter.Update(myDataSet) to make the changes
    in the database. I've been looking for this and i can't seem to find a way
    to do it though.

    I found a lot of examples using a string or stored procedure to update the
    values through a new Command object, but i was wondering why i shouldn't use
    the automaticly generated update, delete, insert of my typed dataset? To
    find the row i want to update i'd do something like this
    myTypedDataRow = myTable.Rows.FindById(selectedId);

    Now my biggest problem is how do i find the selectedId of the row just
    edited? I already set the Key on the datagrid, so it knows the key of my
    datatable, yet all the fancy methods on my DataGridEventArgs (or what it's
    called - i don't have VS/my project here) all just return the index in the
    datagrid - so since the Id is not the same as the index in the datagrid i
    can't use it.

    Anyone know how to solve this or have a good tutorial on DataGrids? I
    searched for a good one, but only found very simple examples that didn't
    cover my problem :(

    Thanks!
    Per


    Per Hornshøj-Schierbeck Guest

  2. Similar Questions and Discussions

    1. Typed DataSet Question
      I've created a Typed DataSet to manage a Shopping Cart for a Website. I'm trying to rewrite one of the events to check if the the ProductID already...
    2. xsd.exe Typed DataSet generation
      Hello, I am loading a DataSet from an xml file and binding it to a hierarchical datagrid. I am trying to write some keys between the elements...
    3. web service newbie dataset question
      Could someone please tell me whether the following is possible? I'm especially murky about step #5 :-) I'd be very grateful for pointers to an...
    4. Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset
      Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data...
    5. typed dataset mysql
      is there any way to "auto-generate" a typed dataset from a MySQL database from Visual Studio .NET? thanks
  3. #2

    Default Re: updating a typed dataset (newbie question?)

    Per,

    I assumed you were Windows.Forms because ASP.NET data binding is inherently
    one way.

    You have to work out your own updating strategy.

    Kathleen


    "Per Hornshøj-Schierbeck" <nospam@microsoft.com> wrote in message
    news:#ucTpKxRDHA.212@TK2MSFTNGP10.phx.gbl...
    > Hi Kathleen!
    >
    > Thanks for the relpy - i'll try and comment :) Perhaps i forgot to mention
    > that this is an ASP.NET project, actually i only do ASP.NET so that's why
    i
    > forgot to mention it's not a winforms project. Perhaps that's why it's not
    > working?
    >
    > > Your datagrid is updating your DataSet, or should be. Don't have any
    > > AcceptChanges between the Fill and Update (actually don't have any
    unless
    > > you are really certain you understand why you need them)
    >
    > Yep, if i call AcceptChanges the RowStatus will change and they won't get
    > updated when i call .Update()
    >
    > > Your typed DataSet does not have Insert, Deleted, Upate, etc. commands,
    > > assumign you are usng the Microsoft typed dataset generator and have not
    > > extended it.
    >
    > When i check the design-generated code all the commands are there - so
    they
    > should be there? I also checked when i created the dataset.
    >
    > > > Now in a perfect world the datagrid, bound to my view would have a
    > method
    > > > for updating the selected row of the dataset/view with the templated
    > > values.
    > > > All i had to do is call myDataAdapter.Update(myDataSet) to make the
    > > changes
    > > > in the database. I've been looking for this and i can't seem to find a
    > way
    > > > to do it though.
    > >
    > > That is all you have to do. Do you have your DataAdapter, and DataSet
    > > available?
    >
    > Ok great! How come there are no examples of this automaticly update? Hold
    on
    > a second - i'm using ASP.NET and not winforms - is there a difference
    there?
    >
    >
    > > > Now my biggest problem is how do i find the selectedId of the row just
    > > > edited? I already set the Key on the datagrid, so it knows the key of
    my
    > > > datatable, yet all the fancy methods on my DataGridEventArgs (or what
    > it's
    > > > called - i don't have VS/my project here) all just return the index in
    > the
    > > > datagrid - so since the Id is not the same as the index in the
    datagrid
    > i
    > > > can't use it.
    > >
    > > I am not clear why you need it. The currency manager associated with
    your
    > > DataGrid has a Current method.
    >
    > How do i access that? Perhaps i forgot to tell it's an <asp:DataGrid>
    > control i'm using for asp.net and not winforms - is that only available
    for
    > winforms?
    >
    > > > Now my biggest problem is how do i find the selectedId of the row just
    > > > edited? I already set the Key on the datagrid, so it knows the key of
    my
    > > > datatable, yet all the fancy methods on my DataGridEventArgs (or what
    > it's
    > > > called - i don't have VS/my project here) all just return the index in
    > the
    > > > datagrid - so since the Id is not the same as the index in the
    datagrid
    > i
    > > > can't use it.
    >
    > I figured this part out, even though i shouldn't need this if i get the
    > automaticly update to work.
    > The trick was using either
    > myDataSet.myTypedTable.Rows[e.Item.ItemIndex];
    > or access the .DataKeys[e.Item.ItemIndex] to get the key value ;)
    >
    > Per
    >
    >

    Kathleen Dollard Guest

  4. #3

    Default Re: updating a typed dataset (newbie question?)


    "Kathleen Dollard" <kathleen@mvps.org> wrote in message
    news:%23z83cx8RDHA.2480@tk2msftngp13.phx.gbl...
    > Per,
    >
    > I assumed you were Windows.Forms because ASP.NET data binding is
    inherently
    > one way.
    >
    > You have to work out your own updating strategy.
    >
    > Kathleen
    Nod thanks :) I found a way (actually two different ones i posted earlier)
    to do it so it's cool. I just wanted to make sure i wasn't doing it the hard
    way (if there was an easier one).


    Per Hornshøj-Schierbeck Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139