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


when clicking deletion button corresponding row deleted. remaining rows in gridview become invisibe. displays correctly when click linkbutton again . please me. code here:

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 student_details e join student_vs_testsession_details f on e.student_id=f.student_id 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 student_vs_testsession_details 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();   } 

what doing here deleting database not table.(which table assigned grid)

so in case either need repopulate datatable after deleting row or manually delete row datatable bound gridview

what can add

linkbutton2_click(null,null) after gridview1.visible = true; in deleting function

or rewrite dataset function.

but dont forget ,everytime need assign table gridview

hope helps


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -