Link to home
Start Free TrialLog in
Avatar of David Svedarsky
David SvedarskyFlag for United States of America

asked on

How to add multiple rows to datagridview with butten click

Using a bound datagridview.
I need sample code to add multiple rows to a datagridview with butten click event.

I need to add 24 blank rows with one click event.
Avatar of surajguptha
surajguptha
Flag of United States of America image

Since you are using a bound datagrid, just add 24 more records to the list or datatable which you are binding to the grid and do a databind again.
Avatar of David Svedarsky

ASKER

I want to do this instantaneously with a button click event. Not one row at a time.
On the Buttom Click you can add all the 24 records so after the button click u would see 24 blank records.
It would appear as if all 24 were inserted. It would appear row by row
I don't really understand what you are trying to explain.

Maybe you can show me some sample code as requested in my opening question.
If you did DataGrid.DataSource = dtTableData;
on Button1_Click()
{
for(int i =0; i < 24; i++)
{
dtTableData.Rows.Add(DtTableData.NewRow());
}
DataGrid.DataSource = dtTableData;
}
I think you may have the solution but I can't convert all the C# code to VB.Net.
For index As Integer = 1 To 24
            dtTable.Rows.Add(dtTable.NewRow())
        Next
        dgrid.DataSource = dtTable
I'm not familiar with your code.
Can you complete this?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
???????????

End Sub

DataGridview: TblJobOrdersDetailDataGridView
Table: TblJobOrdersDetail
DataSet: MonarhSQL
ASKER CERTIFIED SOLUTION
Avatar of surajguptha
surajguptha
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
surajguptha,
This works good.

Thank you.