Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGridView Adding Row Problem
 

DataGridView Adding Row Problem

I have a datagridview. I disable its AllowUsertoAddRows property. This datagridview is bound to a bindingsource. I am adding rows using bindingsource.addnew(). Afterfinishing entering the data in the last column, which is a mandatory columnI call update function of the tableadapter. I am getting errors that says the last column does not allow nulls. Even though I entered the data before calling the update function.
  • Moved byOmegaManMVPSaturday, August 22, 2009 11:48 PM (From:Visual C# Language)
  • Moved bynobugzMVP, ModeratorSunday, August 23, 2009 4:26 PMnot a bcl q (From:Windows Forms General)
  •  
UrNot  Saturday, August 22, 2009 10:09 AM
Hi UrNot,

We need to call the EndEdit method of the DataGridView and the BindingSource before we update the data to database. This is the code:
dataGridView1.EndEdit();
bindingSource1.EndEdit();

Let me know if this helps.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Tuesday, August 25, 2009 12:25 PM
Hi UrNot,

We need to call the EndEdit method of the DataGridView and the BindingSource before we update the data to database. This is the code:
dataGridView1.EndEdit();
bindingSource1.EndEdit();

Let me know if this helps.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Tuesday, August 25, 2009 12:25 PM
Hi UrNot,

We need to call the EndEdit method of the DataGridView and the BindingSource before we update the data to database. This is the code:
dataGridView1.EndEdit();
bindingSource1.EndEdit();

Let me know if this helps.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Tuesday, August 25, 2009 12:26 PM

You can use google to search for other answers

Custom Search

More Threads

• How do I have a combo box column display a sub set of data based upon the value of a different combo box column?
• Switch from ASP.NET to .NET WinForm
• Data not updated unless controls loose focus first.
• DataGridViewRow - why does it require a default property?
• There is any way to identify an handler is exist of not
• Devexpress vertical grid control data biniding
• Concurrency violation error
• How Do I Add TextBox & ComboBox Text To A DataGrid Thats Been Binded To A Access Database?
• Multiple comboboxes reset to the first index on -1
• Gridview problem and Question