Refer the code below:
void loadInstallMentPattern(System.Collections.ArrayList pattern)
{
dataGridView1.Rows.Clear();
for (int i = 0; i < pattern.Count; i++)
{
int c = dataGridView1.Rows.Add();
dataGridView1.Rows[c].Cells["gvcSNo"].Value = (i + 1).ToString();
dataGridView1.Rows[c].Cells["gvcDueDate"].Value = ((InstallmentPatternStruct)pattern[i]).DueDate;
dataGridView1.Rows[c].Cells["gvcAmount"].Value = ((InstallmentPatternStruct)pattern[i]).PrincipalAmt;
dataGridView1.Rows[c].Cells["gvcInterestAmt"].Value = ((InstallmentPatternStruct)pattern[i]).InterestAmt;
dataGridView1.Rows[c].Cells["gvcDebitAmt"].Value = ((InstallmentPatternStruct)pattern[i]).DebitPrincipalAmt;
dataGridView1.Rows[c].Cells["gvcEMI"].Value = ((InstallmentPatternStruct)pattern[i]).EMI;
}
}
I have pragmatically added a few rows to DataGridView which are required to be further send to database for persistence.
Currently I am sending the data by reading each row from grid and then sending it to db. This means if I've 500 rows in DataGridView, then I'll have to fire 500 Insert queries.
I was wondering is there any other way to send data to db(in bulk) in case where DataGRidView is not data bound.
I hope I am able to explain my problem clearly. Any help would be greatly appreciated.