DataGrid Delete Confirmation and Item Color Alternation

zhaozj2021-02-16  49

DataGrid Delete Confirmation and Item Color Alternation

HBZXF (A Ho) http://www.cnblogs.com/hbzxf

Sometimes we need to delete data corresponding to Item in the DataGrid, you need to pop up a confirmation dialog to prompt the user. In fact, this feature is very simple. The following code can try, there is a small skill, also test it. Color alternating effects can be generated in the DataGrid Item.

private void dg_ItemDataBound (object sender, DataGridItemEventArgs e) {if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {// deletion confirmation LinkButton delBttn = (LinkButton) e.Item .Cells [1] .controls [0]; Delbttn.attributes.add ("onclick", "JavaScript: Return Confirm ('OK Delete" E.Item.cells [4] .text ");") (// Color Alternates E.Item.attributes.add ("OnMouseOver", "this.style.BackgroundColor = 'Seashell'); if (E.Item.ItemType == ListItemType.Item) {E.Item.attributes. Add ("onmouseout", "this.style.backcoundcolor = '# fffff'");

IF (E.Item.itemType == ListItemType.alternatingItem) {E.Item.attributes.add ("onmouseout", "this.style.backroundcolor = 'seasonell');}}}

Thank you, my friend Xiaolin has provided technical support here, he is an excellent software engineer.

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

New Post(0)