When deletion button of one row is clicking the entire gridview become invisible

chuongprocf

New Member
When I clicking deletion button then corresponding row is deleted. But the remaining rows in gridview become invisibe. But it displays correctly when I click those linkbutton again. Please help me. Code is here:\[code\]protected void LinkButton2_Click(object sender, EventArgs e){try { SqlConnection con = obj.getcon(); con.Open(); GridView1.Visible = true; SqlDataAdapter adapter = new SqlDataAdapter("select e.student_id,e.student_name,e.student_nric from student_details e join student_vs_testsession_details f on e.student_id=f.student_id where f.testsession_id='" + lb_testid.Text + "' ", con); adapter.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); } catch (Exception ex) { Response.Write(ex); }} protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string id =Convert.ToString (GridView1.DataKeys[e.RowIndex].Value); SqlConnection con = obj.getcon(); con.Open(); SqlCommand cmd = new SqlCommand("DELETE FROM student_vs_testsession_details WHERE student_id='" + id + "'", con); // con1.Open(); int temp = cmd.ExecuteNonQuery(); if (temp != 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert(' record deleted succesfully')", true); } con.Close(); GridView1.Visible = true; GridView1.DataBind(); }\[/code\]
 
Top