Added the delete button after binding data.
<Asp: button id = "btndelete" commandname = "deleteshoppingcar" commandargument = '<% # eval ("SC _shoppingcarno ") %> 'runat = "server" text = "[delete]" cssclass = "input-button-2 float_left" style = "margin-Right: 5px;"/>
However, an error will be reported after clicking
The callback parameter is invalid. Use <pages enableeventvalidation = "true"/> in the configuration, or use <% @ page enableeventvalidation = "true" %> On the page to enable event verification. For security purposes, this function verifies whether the parameters of the send-back or callback events come from the server controls that initially present these events. If the data is valid and is expected, use the clientscriptmanager. registerforeventvalidation method to register the resend or callback data for verification.
Subsequent troubleshooting found that the control was re-bound
protected void Page_Load(object sender, EventArgs e) { Data_Bind(); }
Change
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { Data_Bind(); } }
Only OK. onitemcommand is modified as follows:
/// <Summary> //// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E "> </param> protected void lstvshowshoppingcar_itemcommand (Object sender, listviewcommandeventargs e) {If (E. commandname = "deleteshoppingcar") // Delete the cart {string shoppingnum = E. commandargument. tostring (); string r_result = NULL; new shopping_carhelper (). deleteshopping_cartbyshoppingcarno (shoppingnum, out r_result); data_bind (); alert (r_result );}}