How to update a dataset table row I have previously added ?

B

Bishman

Hi,

C# App. VS2005

I have a detail table ordered descending on a field called DetailRowID

ie
ArrayIndex Detail RowID
0 3
1 2
2 1

I add a new row but it goes to the end of the dataset so does not

ArrayIndex Detail RowID
0 3
1 2
2 1
3 4

I then need to subsequently update the row I have just added. What is the
proper way to refer to that row ? I usually set the field values using
DatasetName.TableName[0].Fieldname notation, however that is the previously
entered row (Index=0) and not the one just added (Index = 3). Do I need to
refresh the dataset table so my new row is at index 0 and then I know where
it is - or just work out the index value of the new record by using the
number of rows in the DS before I added my new one, or neither ? I
appreciate this is probably totally wrong however I havent got to grips with
databinding yet and just need to get this done !

Thanks,

Jon
 
E

Earl

This seems to be a common question lately. I'm assuming your DetailRowID is
an autoincrement. The simplest technique is to use a negative autoincrement
in the datatable in order to determine which rows are newly added. So your
rows might look like:

DetailRowID
2 (existing)
3 (existing)
1 (existing)
-1 (new)
 

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

Top