Guest User

Untitled

a guest
Jun 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public partial class WebForm2 : System.Web.UI.Page
  2. {
  3. protected void Page_Load(object sender, EventArgs e)
  4. {
  5. GridView1.DataSource = SqlDataSource1;
  6. GridView1.DataBind();
  7. }
  8.  
  9. protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  10. {
  11. if (e.CommandName == "btn")
  12. {
  13. int crow;
  14. crow = Convert.ToInt32(e.CommandArgument.ToString());
  15. string v = GridView1.Rows[crow].Cells[1].Text;
  16. int a = Int32.Parse(v);
  17. string b = "true";
  18. SqlConnection con = new SqlConnection("Data Source=DESKTOP-LITEG8T;Initial Catalog=UserDb;Integrated Security=True");
  19. con.Open();
  20. SqlCommand cmd = new SqlCommand("UPDATE Table_1 SET Status ='"+b+"' WHERE Id ='"+ a+"'", con);
  21. cmd.ExecuteNonQuery();
  22. con.Close();
  23. v = "";
  24.  
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment