Want more features on Pastebin? Sign Up, it's FREE!
Guest

ccc

By: a guest on Apr 13th, 2012  |  syntax: C#  |  size: 0.83 KB  |  views: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.   protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  2.         {
  3.             int index = Convert.ToInt32(e.CommandArgument);
  4.             string sqlQuery = "Update mytable set ID = @ID WHERE No ="+ index;
  5.             GridOpen(sqlQuery);
  6.  
  7.         }
  8.         void GridOpen(string send)
  9.         {
  10.             string con = "conn string";
  11.             using (SqlConnection dataConnection = new SqlConnection(con))
  12.             {
  13.                 using (SqlCommand dataCommand = new SqlCommand(send, dataConnection))
  14.                 {
  15.                     int ld = 121;
  16.                     dataCommand.Parameters.AddWithValue("ID", ld);
  17.                     dataConnection.Open();
  18.                     dataCommand.ExecuteNonQuery();
  19.                     dataConnection.Close();
  20.  
  21.                 }
  22.  
  23.             }
  24.         }
clone this paste RAW Paste Data