P
Per Hornshøj-Schierbeck
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
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