title: how to use delete command in grid view for updation
body: <p>i have 3 web pages. admin,student and teacher. i have used grid view on each of this page.my table is having a column as 'status'.which is having default value 0. I want to update this value to 1 when i click on delete in gridview. I have written following code. But it is not working.pls help.</p>
  
  <p>this is .aspx file code-</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:TEMPRUJUConnectionString %&gt;" 
   SelectCommand="SELECT * FROM [login] WHERE ([username] = @username)" 
   DeleteCommand="UPDATE [login] SET [status]= 1 WHERE [id]=@id" 
   InsertCommand="INSERT INTO [login] ([name], [midname], [surname], [username], [password], [contact], [dob], [email], [address], [occupation], [ltype]) VALUES (@name, @midname, @surname, @username, @password, @contact, @dob, @email, @address, @occupation, @ltype)" 
   UpdateCommand="UPDATE [login] SET [name] = @name, [midname] = @midname, [surname] = @surname, [username] = @username, [password] = @password, [contact] = @contact, [dob] = @dob, [email] = @email, [address] = @address, [occupation] = @occupation, [ltype] = @ltype WHERE [Id] = @Id"&gt;
          &lt;DeleteParameters&gt;
              &lt;asp:Parameter Name="Id" Type="Int32" /&gt;
          &lt;/DeleteParameters&gt;  
  </code></pre>
  
  <p>and this is my code behind-</p>
  
  <pre><code>protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  {
      SqlConnection con = new SqlConnection("Data Source=SNEHAL-PC\\SNEHAL1;Initial Catalog=TEMPRUJU;Integrated Security=True");
      SqlCommand cmd;
      SqlDataReader dr;
      con.Open();
      GridViewRow row = GridView1.Rows[e.RowIndex];
      cmd=new SqlCommand("Update login set status=1 where id='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'",con);
      dr = cmd.ExecuteReader();
  }
  </code></pre>