inserting a row in dataset

A

Abubakar

Hi,
Lets say I have 3 rows in a dataset bound to a datatgrid. Now I want to add
a new blank row before the second row in the dataset. How am I going to do
that? I think there was an insertat method of dataset that I tried but wasnt
working correctly. A short working code will help.

I'm doing this in vs.net 2k3.

Thanks,

Ab.
 
M

Marina

I recommend you post ADO.NET questions in the ADO newsgroup.

In any case, I have found this to be buggy. The problem is that the DataView
does not refresh itself with the correct row positioning. No matter where
you add the row, it shows up at the end of the list, even though in the
underlying DataTable it is in the right spot. And whenever you bind to a
datatable, you are really binding to its DefaultView property which is a
DataView.

Now, I think I remember there being some sort of argument that this is by
design - but I just don't get it. If I add a row in the middle, I expect
the DataView to refresh itself.

Your options are to create a brand new DataView after the insert and bind to
that.
Or, to not use the dataset as a datasource and to write your own collection
you can bind to (ok, this could turn into a lot of work).
And the last option is to not allow the user to insert rows in the middle.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top