469,964 Members | 1,546 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

adding empty row to databound datagrid

Jim
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.

Nov 15 '05 #1
2 9812
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
"Jim" <NA> wrote in message news:ee****************@TK2MSFTNGP09.phx.gbl...
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.

Nov 15 '05 #2
Jim
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.

"William Ryan" <do********@comcast.nospam.net> wrote in message
news:eQ**************@TK2MSFTNGP11.phx.gbl...
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
"Jim" <NA> wrote in message

news:ee****************@TK2MSFTNGP09.phx.gbl...
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.


Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tonya | last post: by
1 post views Thread by Patrick Demets | last post: by
1 post views Thread by GaryDean | last post: by
6 posts views Thread by =?Utf-8?B?QmVuLg==?= | last post: by
3 posts views Thread by dbuchanan | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.