javascript - How to delete a row in gridview after clicking the delete button in a form -


i have aspx page has gridview 3 fields , 1 button "update". when click on update button i'll redirected aspx page has form more information entry in grid view selected clicking button "update". form contains more fields , button "delete". when click button "delete" need close opened form , go gridview , delete entry. i'm using templatefield gridview.

<asp:gridview id="gridview1" runat="server">    <columns>      <asp:templatefield showheader="false" headertext=" ">           <itemtemplate>               <asp:button id="btn_update" text="update" runat="server" buttontype="button" commandname="update" />           </itemtemplate>       </asp:templatefield>         <asp:boundfield datafield="id" headertext="id" />         <asp:boundfield datafield="firstname" headertext="first name" />         <asp:boundfield datafield="lastname" headertext="last name"  />     </columns> </asp:gridview> 

this code after click button "delete" in form close , go gridview:

 protected void btn_delete_click(object sender, eventargs e) {      #region redirect page     page.clientscript.registerstartupscript(this.gettype(), "refreshparent", "<script language='javascript'>refreshparent()</script>");     response.write("<script>window.close();</" + "script>");     #endregion      cleardata(); } 

how can delete row gridview after clicking button "delete" in form? thank all

here's sample code you'd idea. it's wpf + c#, not web, should drift. idea same.

your main program:

public delegate void deleterow(bool dodelete);  /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : window {     int selectedrow = 0;     public deleterow deleterowdelegate;      public void reportdelete(bool delete)     {         // delete row here.     }      public mainwindow()     {         initializecomponent();         deleterowdelegate += new deleterow(reportdelete);     }      private void btnok_click(object sender, routedeventargs e)     {                     // here, row number selectedrow.          secondarywin win = new secondarywin(deleterowdelegate);         win.showdialog();          // @ point, if delete clicked in secondary window, code have executed reportdelete() method.     } } 

and secondary window:

public partial class secondarywin : window {     deleterow callbackdel;      public secondarywin(deleterow callback)     {         initializecomponent();         callbackdel = callback;     }      private void btndel_click(object sender, routedeventargs e)     {         callbackdel.invoke(true);         // close window     } } 

so in main register reportdelete() method deleterow delegate, , pass secondary window. i've passed in constructor, use different method if wishes.

then in secondary window call delegate when click delete button, , exit window.

back in main(), whenever delete clicked in secondary window execute code inside reportdelete() method delete particular row. use selectedrow purpose.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -