We know that if the width of DataGrid is longer so that we can make it easy to clear the line of data, it is easy to make us look wrong, I think if our mouse moves to the DataGrid line, he can clearly show us Ok, now, now we start, first we know that DataGrid is explained in the client to Table so we know that Table has TR and TD composition, TR is line, we only need to join onMouseover on each TR. A javaScript script can implement this function,
... td > tr> table> This is the script from the client. Then we can join this script when we can add this script to the ItemDatabase event of the binding data. The specific code is as follows: IF (E.Item.itemType == ListItemType.Item || E.Item.ItemType == ListItemType.alternatingItem) {E.Item.attributes.add ("onmouseover", "this.style.backgroundcolor = ' Silver '"); E.Item.attributes.add (" onmouseout "," this.style.backgroundcolor =' white ');} This will change the color into Silver when the mouse moves into Silver. Cheng WHITE. The previous judgment can also have the same effect when the mouse moves to HEAD and FOOT, which can only generate the script only on items.
Or specify a column discoloration: if (E.Item.itemType == ListItemType.Item || E.Item.itemType == ListItemType.alternatingItem) {E.Item.cells [2] .attributes.add ("OnMouseOver", " This.style.BackgroundColor = 'Silver' "); E.Item.cells [2] .attributes.add (" onmouseout "," this.style.BackgroundColor = 'White');} Not only so you can also specify the mouse Moving to a column shape: E.Item.cells [3] .Style ("cursoor") = "Hand" or click a single unit display prompt information: E.Item.cells [3] .attributes.add ("Onclick", "Alert ('you click on the ID is:" E.Item.cells [0] .text "!');"), etc., we can also add it in the mouse by this method. The effect of prompts in the line E.Item.cells [2] .attributes.add ("Title", "Title can add prompt information"); After the practice, you can add a lot of JavaScript scripts when you are bound. Your DataGrid looks more vivid. Finish! Cuike519 [original] author blog: