Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hiii
can u pls help me , how to insert multiple details in database from gridview control

pls it's urgent
Posted

Hi ,
try this
C#
 protected void btnview0_Click(object sender, EventArgs e)
    {
 
        callgrid();
    }  
 protected void Btnrecv_Click(object sender, EventArgs e)
  { 
      foreach (GridViewRow item in GridView1.Rows)
        {
 
//here your connection string 
            SqlConnection con = new SqlConnection(@"Here YOUR connection ");
            con.Open();
//Modified according your table Definition 
            string statment = string.Format("insert into  test1 ( [name], [address], gender ) values ('{0}','{1}','{2}' )", item.Cells[1].Text , item.Cells[2].Text, item.Cells[3].Text);
            SqlCommand cmd = new SqlCommand(statment, con);
 
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();
            con.Close();
            cmd.Dispose();
 
        }
   } 
 
Share this answer
 
Comments
jyoti123123 1-Aug-12 7:46am    
sir please how to insert multiple records in database from gridview control
in WPF
FASTLY REPLY

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900