how best to edit data in a data grid

T

T.Jackson

Hi guys,

I want to display the data of a table in a datagrid in one form,
& enable the user to edit the details of a particular record in another
form.

I want the following features,
1. display the data in a grid in one form
2. enable editing the data for a row in another form
3. checking if changes have been made, reverting the changes, saving the
changes
when editing the data of a particular record
(can use the revertchanges, acceptchanges & rowstate of the Row object).

Now how do go about doing this?
1. Pass the dataset & the row position to the next form,
2. bind the data
3. set the row position
4. then use the rowstate, rejectchanges and acceptchanges method of the row
object.

Is this the best (standard) way of editing data in a grid?????
Please do let me know,
as i'm new to vb.net & would like to adopt the best techniques from the
start...
(NOTE : Here I want more help in the architecture rather than coding)
 
C

Cor

Hi TJ,

No that is not why a datagrid is made for, you can do all you editing in the
datagrid, and if you make a button for saveall, resetall, and deleterow, it
is very easy.

You have to make a dataset, fill that using a dataadaper and bind that using
the datasource from the datagrid to that.

You can save the dataset using the dataadapter.update after you have done a
endcurrentedit using the bindingcontext and check if that
mydataset.haschanges

To reset you can use mydataset.rejectchanges.

You need very few code and the most is very simple, until you start making
it nicer, but that is in your other approach also..

I hope this helps?

Cor
 
T

T.Jackson

Oki doki,
thanx,

Cor said:
Hi TJ,

No that is not why a datagrid is made for, you can do all you editing in the
datagrid, and if you make a button for saveall, resetall, and deleterow, it
is very easy.

You have to make a dataset, fill that using a dataadaper and bind that using
the datasource from the datagrid to that.

You can save the dataset using the dataadapter.update after you have done a
endcurrentedit using the bindingcontext and check if that
mydataset.haschanges

To reset you can use mydataset.rejectchanges.

You need very few code and the most is very simple, until you start making
it nicer, but that is in your other approach also..

I hope this helps?

Cor
 
C

ccoston

I understand that the easiest way to edit data in a datagrid is directly through the datagrid, but I understand what T. Jackson was requesting and I would like to know how to do it too. I have a datagrid that pulls from a dataset that only includes necessary columns to browse through a customer list. I want to be able to either double-click the row of the customer I want to edit, or highlight the row and click an "edit" button. This should bring up a new form that allows the user to edit ALL attributes of the particular customer record through textboxes/checkboxes and such. I'm new to .NET, so maybe there is an easier way to do this than to use the datagrid. Can anyone elaborate on this

Thanks.
 
C

Cor

Hi ccoston,

If you have a question, post it as a new message, this seems as an answer,
while it is not, you can get a lot of samples on your questions here

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbrkit/faq/#installvdir
I hope this helps a little bit?

Cor

I understand that the easiest way to edit data in a datagrid is directly
through the datagrid, but I understand what T. Jackson was requesting and I
would like to know how to do it too. I have a datagrid that pulls from a
dataset that only includes necessary columns to browse through a customer
list. I want to be able to either double-click the row of the customer I
want to edit, or highlight the row and click an "edit" button. This should
bring up a new form that allows the user to edit ALL attributes of the
particular customer record through textboxes/checkboxes and such. I'm new
to .NET, so maybe there is an easier way to do this than to use the
datagrid. Can anyone elaborate on this?
Community Website: http://www.dotnetjunkies.com/newsgroups/
 

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