Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void btnedit_Click(object sender, EventArgs e)
        {
            
           

            DialogResult dr = MessageBox.Show("Are you sure to save Changes", "Message", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
            if (dr == DialogResult.Yes)
            {

               
                   con.Open();
                 
                    string strQuery = "update tblProducts set ProductsId='" + textBox1.Text+ "',CategoryName='" + comboBox1.Text + "',ProductsName='" + txtpname.Text + "',ProductsDescription='" + txtpdes.Text + "',ProductsPrice='" + txtpprice.Text + "' where ProductsId=" + textBox1.Text;
                    SqlCommand cmdSelect = new SqlCommand(strQuery, con);
                    cmdSelect.ExecuteNonQuery();
                    con.Close();
                  // bindgrid();

                
            }
           
           
        }
Posted

1 solution

After update operation you must rebind your DataGridView.

Hope it helps.
 
Share this answer
 
Comments
rockpune 27-Aug-12 11:06am    
not working
Christian Amado 27-Aug-12 11:09am    
The update executes changes on database?

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