Click here to Skip to main content
15,067,335 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear All,

I have one datagridview in my project. I am developing it for connected mode.
I have one Add_New_Row button and I want to add a new blank row in last row i.e. footer and there is condition that row will be added if there is any data in its previous row and only one row will be added.

suppose last row shows Product_id=101,Product_name="Lux",Product_Price=30, then
if I click Add_New_Row button only one blank row will be added, and again if I click on Add_New_Row button nothing will happen and it will should an error message that last row can not be left blank. Moreover, if user add new row and doesn't do anything will it and click on save button then it should show message
" Current row can not be left blank ".


Thanks & Regards,
Ravindra
Posted
Comments
Sascha Lefèvre 7-Apr-15 23:08pm
   
Is it for WinForms?
Ravindra_IND 7-Apr-15 23:45pm
   
yes.....it is for windows form
Sascha Lefèvre 7-Apr-15 23:56pm
   
You don't want to use dataGridView.AllowUserToAddRows=true ?
Sascha Lefèvre 8-Apr-15 1:15am
   
What do you use as your DataSource for the DataGridView? A DataTable / DataView ?
Ravindra_IND 8-Apr-15 1:39am
   
data table
Sascha Lefèvre 8-Apr-15 6:42am
   
There should be a blank row after the last existing row where the user can enter a new record. And it basically behaves as you want - just without a button required. If you enter something, a new blank line appears. This is standard behaviour and if it doesn't show for you, you probably have dataGridView.AllowUserToAddRows set to false somewhere.
   
Where is the exact issue?
Ravindra_IND 8-Apr-15 0:21am
   
Hmm... I am newbie in this..so I don't have proper idea about it....I placed my query just here...and will follow the best suggestion given by you...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900