Hi all.
I'm trying to figure out how to get the DataGridView control to work when AllowUserToAddRows = true.
I can bind fine the gridview to the access database, but when I try to add a record, meaning as soon as I start to type, the private void dataGridView1_UserAddedRow(object sender, DataGridViewRowEventArgs e) event fires and adds a blank record (or fails when i re-add the validation). Have tried it using a few other events, but this was the only one that actually added the data to the database.
Any help or suggestions would be appreciated. I also need to know how I can get the value of the cell for the selected row...ie, value for address1, address2, city, etc. So that I can (if I end up having to) run the TableAdapter.Insert(param1, etc).
Thanks in advance,
Frank
Loading
frankPosted Dec 21, 2009, 3:15 PM
Thanks for the quick reply but when I tried using it, never even fired, and no clue why it wouldnt. Everything else seems to fire.
I must be missing something obvious. It's the only thing I can think of, othewise MS would have created a DataGridControl that can be bound to a strongly typed dataset, and not be able to do any update,insert,delete functions. Just able to display the data....seems like an obvious place to build those things into the control so I'm thinking I'm screwed up someplace obvious...though I cant think of where.
At one point I had it inserting on rowleave...was able to isolate the inserted row by the -# the gridview used for the ID. PRoblem with that was even if the last field was populated, when you tabbed or clicked on another row, the rowleave would fire, but the last field would be blank..each and every time.
Thanks and sorry for the rant at the end...frustrated & used to doing web development, not windows....lots of new stuff to learn, very short time to learn it.,
Frank
Kirtan PatelPosted Dec 20, 2009, 8:47 PM
try NewRowAdded Event ...
private void dataGridView1_NewRowNeeded(object sender, DataGridViewRowEventArgs e)
{
}