DataGrid Delete Confirmation and Item Color Alternation

xiaoxiao2021-03-06  39

Sometimes we need to display data corresponding to the 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 generate color alternating effects 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');}}}

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

New Post(0)