adding empty row to databound datagrid

  • Thread starter Thread starter William Ryan
  • Start date Start date
W

William Ryan

You can add a new DataRow to the DataTable, you can use a bindingContext or
BindingManagerBase and use the .AddNew() method. Is the grid supposed to be
read-only for everything but new Rows? I'm not sure if I'm understanding
correctly.

As far as updating goes, do you mean the Data in the DataBase? Since it's a
WinApp, I'm assuming your grid is bound to a DataTable. Any changes made
through the grid will be reflected in the DataTable. So you can simply call
DataAdapter.Update(yourTable) and provided you have update Logic , that's
all you should need. If you havne't used a DataAdapter Configuration
Wizard, you'll need to either use a CommandBuilder or roll out your own
stuff.
Either way, it's pretty straightforward. I'm not sure I understand the
problem, but if you can give me a little more detail, I can probably get you
through it.

Cheers,

Bill
 
In my Win App, I have a datagrid that's bound to a dataset. When the form
loads, the datagrid fills. How can I add an empty row to the end of the
datagrid during a button click (similar to pressing Tab when mouse pointer
is on last field of last record of datagrid)? The datagrid's read-only so
the user won't be able to modify it unless he wants to add a new record via
the datagrid (by adding the empty row).
Also, if I modify the datagrid, how can I update the physical data? I only
have the dataset to

Thanks.
 
Thanks for your reply. Sorry for the incomplete post.
The datagrid is read-only because I use it to display data. But if the user
wants to add another record to the grid, he'll click the Add button and a
new empty row will appear in the DG for him/her to add the new record
As for updating, I only have the dataset because that's what the method
returns. I'd like to be able to go through the whole datagrid to see what
has been added.
Thanks.
 
Back
Top