삭제 버튼을 클릭하면 해당 행이 삭제됩니다. 그러나 gridview의 나머지 행은 invisibe가됩니다. 그러나 해당 링크 버튼을 다시 클릭하면 올바르게 표시됩니다. . 도와주세요. 코드는 여기에 있습니다 : 그리드보기의한 행의 삭제 버튼을 클릭하면 전체 gridview가 보이지 않게됩니다.
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();
}
당신이 삭제 한 후 그리드를 바인딩 필요 없다 도움이
희망 당신의 gridview에 테이블을 할당 할 필요가 잊지 해달라고? – pordi
리바 인딩 전에 'DataSouce' 속성을 설정하지 않은 것처럼 보입니다. –