DataGrid mouse list to change color

zhaozj2021-02-16  60

I used to see many colleagues in 9CBS asked how to implement the mouse click to change one color, (I think everyone can be achieved) (I think everyone can be achieved)

Let's go, let's talk about it.

Add code to iTEM_CREATE:

#Region DataGrid Item Create

public void DataGrid_ItemCreate (objectsender, System.Web.UI.WebControls.DataGridItemEventArgs e) {if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {e.Item.Attributes. Add ("OnClick", "JavaScript: Return CG (this);"); // Click to change the color}} #ENDREGION

Client code: (JavaScript):