Home All Groups Group Topic Archive Search About

indexing problem when adding row

Author
16 Oct 2006 3:51 AM
Ant
VS2003 C#
Hi,


I have a form with all txtboxes databound. A list box shows a list of names
which can be used to pick a record (using the find method to return the index
of the row. This index is then used to set the binding context position)

my problem is that when I add a row & accept changes to the table, the list
box (or more likely, the binding context object) seems to have its index
moved one up, so that picking a name now returns the *next* record. This
persists until the application is closed then started again.

Why is this happening? Am I missing out something? Here is how I save the
row...

newRow.contactMobile = frm.Mobile;
newRow.email = frm.Email;


// Add row to table
dsMain.contact.Rows.Add(newRow);

// persist data
daContact.Update(dsMain.contact);

// Accept changes made to the table
dsMain.contact.AcceptChanges();

Thanks greatly for any ideas

Ant

Author
16 Oct 2006 4:26 AM
Ant
Additionally,

for each concurrent row added, the indexing gets offset by one. Three
inserts & the finding row 1 returns row 3.

I've noticed that when the row is added, it is displayed in the listbox at
the bottom of the list, even though it should be sorted in ascending order
alpabetically. This again persists until the app. is restarted st ehich point
it works fine.

Hope this helps

Ant




Show quote
"Ant" wrote:

> VS2003 C#
> Hi,
>
>
> I have a form with all txtboxes databound. A list box shows a list of names
> which can be used to pick a record (using the find method to return the index
> of the row. This index is then used to set the binding context position)
>
> my problem is that when I add a row & accept changes to the table, the list
> box (or more likely, the binding context object) seems to have its index
> moved one up, so that picking a name now returns the *next* record. This
> persists until the application is closed then started again.
>
> Why is this happening? Am I missing out something? Here is how I save the
> row...
>
> newRow.contactMobile = frm.Mobile;
> newRow.email = frm.Email;
>
>
> // Add row to table
> dsMain.contact.Rows.Add(newRow);
>
> // persist data
> daContact.Update(dsMain.contact);
>
> // Accept changes made to the table
> dsMain.contact.AcceptChanges();
>
> Thanks greatly for any ideas
>
> Ant

AddThis Social Bookmark Button