Add confirmation information to the delete control

xiaoxiao2021-03-17  209

Add a confirmation information to the control, the method is as follows: 1. Add confirmation information to the control. public void DataGrid1_ItemCreated (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.editItItem) {/ * content is as follows * /}} method 1, use the control ID to find for custom controls, and use this method very little control. LinkButton BTNDEL = (LinkButton) E.Item.FindControl ("deletework"); btndel.attributes.add ("onclick", "Return Confirm ('Do you really want to delete this row?');"); Btndel.text = "Delete Work"; method 2, use controls to find the index of the control in the table, this applies to the sub-control, such as the own delete button in the DataGrid. TableCell MyTablecell; MyTableCell = E.Item.cells [6]; // Define the reference to "Delete" cells linkbutton btndel = (linkButton) MyTablecell.controls [2]; btndel.attributes.add ("onclick", "Return CONFIRM ('Do you really want to delete this job?') ")") ")"); btndel.id = "deletework"; method 3, recommended plan, first determine the form, find control according to ID, add a reminder information, this is suitable for There are many forms and more controls, which is not easy to confuse, very clear. TableCell MyTablecell; MyTableCell = E.Item.cells [6]; // Define the reference to "Delete" cell reference linkbutton btndel = (linkButton) MyTablecell.FindControl ("deletework"); btndel.attributes.add ("onclick", "Return Confirm ('Do you really want to delete this job?')"); btndel.text = "Delete Work";

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

New Post(0)