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.
this is .aspx file code-
" 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">
and this is my code behind-
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();
}