title: Insert several rows in a gridView without using a 'for' loop
body: <p>I am creating a Attendance System and using grid view to insert the data. There may be many rows on the grid. All things are going well and data are also entering well. But I am using a <code>for</code> loop to check each row. This make the performance quite slow when the number of rows increases. And also the round trips increases with the growing number of rows.</p>
  
  <p>Can anyone provide a better solution for this?</p>
  
  <p>I have modify my CODE according to u all.....but now a problem has arise it is only inserting the last row of the  grid multiple times......Other than this the Code is fine.</p>
  
  <pre><code>MySqlDataAdapter myworkdatta = myworkdatta = new MySqlDataAdapter("SELECT CID,EID,TID,ATTENDENCE FROM EMPLOYEEATT ORDER BY AID DESC LIMIT 1", conn);
                                      DataSet myworkdsatt = new DataSet();
                                      myworkdatta.Fill(myworkdsatt, "EMPLOYEEATT");
  
                                      int i;
                                      for (i = 0; i &lt; emplist_gv.Rows.Count; i++)
                                      {
                                          string tid = emplist_gv.Rows[i].Cells[6].Value.ToString();
                                          string eid = emplist_gv.Rows[i].Cells[0].Value.ToString();
                                          string atid = emplist_gv.Rows[i].Cells[7].Value.ToString();
  
                                          MySqlCommand cmdwk = new MySqlCommand("INSERT INTO EMPLOYEEATT (CID,EID,TID,ATTENDENCE) VALUES (@cid,@eid,@tid,@attendence)", conn);
                                          MySqlParameter spcidatt = new MySqlParameter("@cid", calid);
                                          MySqlParameter speid = new MySqlParameter("@eid", eid);
                                          MySqlParameter sptid = new MySqlParameter("@tid", tid);
                                          MySqlParameter spattendence = new MySqlParameter("@attendence", atid);
  
                                          cmdwk.Parameters.Add(spcidatt);
                                          cmdwk.Parameters.Add(speid);
                                          cmdwk.Parameters.Add(sptid);
                                          cmdwk.Parameters.Add(spattendence);
  
                                          myworkdatta.InsertCommand = cmdwk;
  
                                          DataRow drowk = myworkdsatt.Tables["EMPLOYEEATT"].NewRow();
                                          drowk["CID"] = calid;
                                          drowk["EID"] = eid;
                                          drowk["TID"] = tid;
                                          drowk["ATTENDENCE"] = atid;
  
                                          myworkdsatt.Tables["EMPLOYEEATT"].Rows.Add(drowk);
  
                                      }
  
                                      myworkdatta.Update(myworkdsatt, "EMPLOYEEATT");
  </code></pre>