Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
protected void GridView3_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

GridViewRow row = (GridViewRow)GridView3.Rows[e.RowIndex];
DataTable tableupd = ViewState["CurrentTable"] as DataTable;
SqlCommand cmd = new SqlCommand("Update tableupd set AssignedPriority=@AssignedPriority where JobCode=@JobCode");
GridView3.DataSource = tableupd;
GridView3.DataBind();

}
Posted
Comments
Nandakishore G N 12-May-14 2:35am    
Safihur. Where are you updating? .. are you trying to update database or DataTable...Because, the update query doesn't do anything...
safihur Rahuman 12-May-14 6:33am    
update datatable
Nandakishore G N 12-May-14 9:04am    
First check the columns specified are same in the Grid and in the DataTable..
View the link http://www.codeproject.com/Questions/367728/Update-Gridview-using-Datatable

1 solution

C#
SqlCommand cmd = new SqlCommand("Update tableupd set AssignedPriority=@AssignedPriority where JobCode=@JobCode");

You have only declared a SqlCommand object. Do the following...
  • You need to assign its Connection Property to your Database ConnectionString.
  • Then define the parameters you have used in the Command Query that are "@AssignedPriority" and "@JobCode".
  • Open the SqlConnection.
  • At last, Execute the Command using SqlCommand.ExecuteNonQuery Method[^].
 
Share this answer
 
Comments
safihur Rahuman 12-May-14 6:35am    
update datatable
Then update the Table. Why are you are creating a Command?
safihur Rahuman 12-May-14 7:16am    
how update table
What have you tried?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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