How to programmically add multiple rows to datagridview

I need sample code to programmically add a predeterminded number of rows to a bound datagridview with a click event.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dirk HaestProject managerCommented:
Did you already succeed to add 1 row ?
Did you try:
(add all the parameters as an empty string, 0, ... (default values)
dave_skyAuthor Commented:

>>Did you already succeed to add 1 row ?

I get this error message when I use the sample code from ms:
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
Hello Dhaest
If you have a data bound DataGridView, then you have probably a tableAdapter. I think you can add rows throug the tableAdaptor, and the Tableadaptor updates the dataGridView
Dirk HaestProject managerCommented:
Rows cannot be added programatically to the datagridview's collection when control is databound
Solution: To add a row to a databound DataGridView, add the row to the underlying data source (e.g., DataTable or BindingSource).

Example below

DataRow dr;
DataSet ds; // this is bound to DataGridView
// some logic setting up dataset and tables within
dr = ds.Tables[0].NewRow(); // Table[0] of ds is the data I want to display
dr["Column1"] = "Finally";
dr["Column2"] = "Got";
dr["Column3"] = "this";
dr["Column4"] = "Working";
// add row to dataset now

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.