Re: updating a typed dataset (newbie question?) by Kathleen
Kathleen
Fri Jul 11 11:49:19 CDT 2003
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
>
>