Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. dataGridView1.Rows[rowIndex].Cells[columnIndex].Value = value;
  2.  
  3. dataGridView1.Rows[rowIndex].Cells[columnIndex].Value = value;
  4.  
  5. this.dataGridView1.Rows.Add();
  6. this.dataGridView1.Rows[0].Cells[1].Value = "1";
  7. this.dataGridView1.Rows[0].Cells[2].Value = "Baqar";
  8.  
  9. // dgvBill is name of DataGridView
  10.  
  11. string StrQuery;
  12. try
  13. {
  14. using (SqlConnection conn = new SqlConnection(ConnectingString))
  15. {
  16. using (SqlCommand comm = new SqlCommand())
  17. {
  18. comm.Connection = conn;
  19. conn.Open();
  20. for (int i = 0; i < dgvBill.Rows.Count; i++)
  21. {
  22. StrQuery = @"INSERT INTO tblBillDetails (IdBill, productID, quantity, price, total) VALUES ('" + IdBillVar+ "','" + dgvBill.Rows[i].Cells[0].Value + "', '" + dgvBill.Rows[i].Cells[4].Value + "', '" + dgvBill.Rows[i].Cells[3].Value + "', '" + dgvBill.Rows[i].Cells[2].Value + "');";
  23. comm.CommandText = StrQuery;
  24. comm.ExecuteNonQuery();
  25. }
  26. }
  27. }
  28. }
  29. catch (Exception err)
  30. {
  31. MessageBox.Show(err.Message , "Error !");
  32. }
  33.  
  34. //dataGridView1.Rows[RowCount].Cells[0].Value = FEString3;//This was not adding Stringed Numbers like "1","2","3"....
  35. DataGridViewCell NewCell = new DataGridViewTextBoxCell();//Create New Cell
  36. NewCell.Value = FEString3;//Set Cell Value
  37. DataGridViewRow NewRow = new DataGridViewRow();//Create New Row
  38. NewRow.Cells.Add(NewCell);//Add Cell to Row
  39. dataGridView1.Rows.Add(NewRow);//Add Row To Datagrid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement