Delete and modification in DataGrid

xiaoxiao2021-03-06  14

DataTextField = "id" CommandName = "update" DataTextFormatString = "Modify {0}"> // The first column is not displayed, but it records the primary key of the entire GRID record, delete modification according to it Find the corresponding record

Add event handler to Grid

This.DataGrid1.itemCommand = new system.Web.ui.WebControls.DataGridCommandeventHandler (this.excuteItemCommand);

The corresponding processing is as follows

private void ExcuteItemCommand (object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) {string ItemID = e.Item.Cells [0] .Text; if (e.CommandName == "del") {ProductManager.DeleteProduct (ItemID This.response.redirect ("./ myProductList.aspx? Isbuy =" isbuy);} else if (e.commandname == "update") {this.response.redirect ("./ updateproduct.aspx? ProductID = " Itemid " & isbuy = " isbuy);}}

CommandName is from

Come.

// Need to pay attention to the price in Page_Load, ispostback

转载请注明原文地址:https://www.9cbs.com/read-50844.html

New Post(0)