|
-
Aug 12th, 2007, 07:11 AM
#1
Thread Starter
Hyperactive Member
[2005] DatagridView and empty rows
When you click + on my bound DGV to add a row, my form does an .AddNew and passes the newly added DGV row to another "detail" form with unbound text controls. If the user cancels the detail form, however, the empty row is added to the DGV. So when you click the "save" button, there is an error because it's trying to update the database with an empty row.
I need to use this "detail" form method (given to me by someone on this forum). I read in help that you cannot programmatically remove rows from a DGV. Anyone see a way around this?
-
Aug 12th, 2007, 08:44 PM
#2
Re: [2005] DatagridView and empty rows
Your AddNew method is a member of BindingSource that sits between your data source (probably a DataTable) and the UI, i.e. your grid. You can call the RemoveCurrent method of that same BindingSource to remove the row currently selected in the UI, which should be your new row.
-
Aug 13th, 2007, 06:59 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] DatagridView and empty rows
Yes, I tried that but it does not work while within the BindingNavigatorAddNewItem_Click sub. If I put a button on the form and do it, it works. I'll try a timer?
-
Aug 14th, 2007, 01:18 PM
#4
Thread Starter
Hyperactive Member
Re: [2005] DatagridView and empty rows
I'm bumping this because the timer isn't working. To recap:
A bound datagridview has empty rows. It's save/update method fails because of the null/emtpy values in the rows. I either need to do one of the following
A) after using the BindingSource .AddNew method, if the row is empty, delete it.
B) Before executing the save code, check and remove emtpy rows
C) A better idea.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|