Front Code:
<!--Category Information -<DivID= "Newnews"class= "Frm"> <h4>Category Management</h4> <Table> <TR> <th>News number</th> <th>Category name</th> </TR> <Asp:repeaterID= "Rep_content"runat= "Server"> <ItemTemplate> <TR> <TDclass= "Number"><%#Eval("ID")%></TD> <TD><ahref="#"><%#Eval("Name")%></a></TD> <TD><Asp:linkbuttonID= "LinkButton1"runat= "Server"CommandArgument= ' <% #Eval ("ID")%>' Onclientclick= ' return confirm (' OK to delete? ') ' OnClick = "LinkButton1_Click" > Delete</Asp:linkbutton></TD> </TR> </ItemTemplate> </Asp:repeater> </Table></Div>
Background code:
/// <summary>///Delete Category/// </summary>/// <param name= "Sender" ></param>/// <param name= "E" ></param>protected voidLinkButton1_Click (Objectsender, EventArgs e) { if(true) { } //instantiating an action classBll. CATEGORYBLL CBLL =NewCATEGORYBLL (); //get the category ID that you clicked stringResumeid =((( LinkButton) sender). Commandargument.tostring ()); //Delete Category BOOLi =CBLL. Deletecategoryandcomment (Resumeid); //determine whether to delete if(i) {Response.Write ("<script>alert (' Delete succeeded! ') </script>"); //rebind Databindcategory (); } Else{Response.Write ("<script>alert (' Delete failed! ') </script>"); }}
Final effect:
Tip whether to delete, write in the front-end code:
-------------------------------------------
Delete Success!
Asp.net-repeater Control Delete button, click Delete Message