Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void btn_Edit_Click(object sender, EventArgs e)
        {
            con.Open();
                using (sd = new SqlCommand("update Auto_Part_Details set Value_Part= 
                @Value_Part, Auto_Parts_id = @Auto_Parts_id, Repair_id = @Repair_id, 
                New_Old_Part = @New_Old_Part ,Provider_id = @Provider_id , 
                Installation_id = @Installation_id , Notes = @Notes where Job_Card = 
                @Job_Card", con))
                {
                    sd.Parameters.AddWithValue("@Job_Card", txt_Job_card.Text);
                    sd.Parameters.AddWithValue("@Value_Part", txt_Value_Part.Text);
                    sd.Parameters.AddWithValue("@Auto_Parts_id", 
                    Convert.ToInt32(CB_Auto_parts.SelectedValue));
                    sd.Parameters.AddWithValue("@Repair_id", 
                    Convert.ToInt32(CB_Repair_type.SelectedValue));
                    sd.Parameters.AddWithValue("@New_Old_Part", Convert.ToBoolean(x));
                    sd.Parameters.AddWithValue("@Provider_id", 
                    Convert.ToInt32(CB_Providers_desc.SelectedValue));
                    sd.Parameters.AddWithValue("@Installation_id", 
                    Convert.ToInt32(CB_Hand_installation.SelectedValue));
                    sd.Parameters.AddWithValue("@Notes", txt_Notes.Text);
                }

                sd.ExecuteNonQuery();
                con.Close();
        }


What I have tried:

i create grid view to display data which i refresh data that display in grid view when i updata any row ?
Posted

1 solution

You have to re-bind your gridview to populate data after executing
C#
sd.ExecuteNonQuery();
call the method in which you have bind data with your gridview.If any query then please ask again.Happy coding!
 
Share this answer
 
v2

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