// Page code
- <Asp: button id = "button2" runat = "server" text = "modify" oncommand = "button3_command" commandargument = '<% # BIND ("ID ") %> 'commandname = "Update" onclientclick = "Return confirm ('Are you sure you want to modify it? ') "/>
- <Asp: button id = "button3" runat = "server" text = "delete" oncommand = "button3_command" commandname = "Del" commandargument = '<% # BIND ("ID ") %> 'onclientclick = "Return confirm ('Are you sure you want to delete it? ') "/>
// Commandargument obtaining the data ID to be modified commandname indicates deleting or modifying the oncommand indicates the name of the public event.
// Background code
- Protected void button3_command (Object sender, commandeventargs E)
- {
- If (E. commandname = "Update ")
- {
- Response. Redirect ("gchanpin. aspx? Id = "+ E. commandargument. tostring ());
- }
- If (E. commandname = "Del ")
- {
- If (! Bll. chanpin. deletemethod (E. commandargument. tostring ()))
- {
- Response. Write ("<SCRIPT> alert ('deletion failed'); history. Back (); </SCRIPT> ");
- Response. End ();
- }
- Else
- {
- Bindlist ();
- }
- }
- }