Update Button in DataGridView

Posted by Pcjoshi under C# on 1/16/2014 | Points: 10 | Views : 802 | Status : [Member] | Replies : 4
Hi,
how to make datagridview With Update button in C# please provide solution.




Responses

Posted by: muralikrishnasurap-12704 on: 1/16/2014 [Member] Starter | Points: 25

Up
0
Down
Hi You can Use the template column (or) Command Field to get update button in GridView.

Best Regards
Murali Krishna.S

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/16/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Try with the following code:


SqlConnection con = Helper.getconnection();

SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
cmd.CommandType = CommandType.Text;
string PrjName = txtPrjNmae.Text;
string Description = txtPrjdescription.Text;
string Date = txtPrjDate.Text;
string Size = txtPrjSize.Text;
string Manager = txtPrjManager.Text;
cmd.CommandText = "Update Projects set Description='" + Description + "', DateStarted='" + Date + "',TeamSize='" + Size + "',Manager='" + Manager + "' where ProjectName= '" + PrjName + "' ";
MessageBox.Show("Project Details are updated");
dataGridView2.Update();
dataGridView2.Refresh();
cmd.ExecuteNonQuery();
con.Close();


Mark as answer if satisfied....





Thank you,
Govind

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 1/22/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
http://khanrahim.wordpress.com/2010/04/10/insert-update-delete-with-datagridview-control-in-c-windows-application/

If this post helps you mark it as answer
Thanks

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Snaveen on: 2/13/2014 [Member] Starter | Points: 25

Up
0
Down
If you want to do update the records on DataGridview then use itemtemplate and then use linkbutton control and onitemcommand event wrote your code for updation. What ever you given command name in LinkButton control same name you used on itemcommand event itself.

Pcjoshi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response