When a foreigner's blog is displayed, it is said that in the gridview under Asp.net 2.0, when the user uses the mouse to scan rows from top to bottom in the gridview, the effect of showing each row that has been moved is highlighted,
Written in Javascript, which is relatively simple and recorded
<Asp: repeater id = "rptrproducts" runat = "server">
<Headertemplate>
<Div> <Table bordercolor = "Silver" border = "0" width = "50%" cellpadding = "0" cellspacing = "0">
<Tr>
<TD bgcolor = "maroon">
<Strong> <font color = "white"> product ID </font> </strong>
</TD>
<TD bgcolor = "maroon">
<Strong> <font color = "white"> product name </font> </strong>
</TD>
<TD bgcolor = "maroon">
<Strong> <font color = "white"> unitprice </font> </strong>
</TD>
</Tr>
</Headertemplate>
<Itemtemplate>
<Tr id = '<% # databinder. eval (container. dataitem, "productid") %>'
Onclick = 'javascript: repeater_selectrow (this, "<% # databinder. eval (container. dataitem," productid ") %>", true );'
Onmouseover = 'javascript: repeater_mousehover (this );'>
<TD bgcolor = "" valign = "TOP"> <% # databinder. eval (container. dataitem, "productid") %> </TD>
<TD bgcolor = "" valign = "TOP"> <% # databinder. eval (container. dataitem, "productname") %> </TD>
<TD bgcolor = "" valign = "TOP"> <% # databinder. eval (container. dataitem, "unitprice") %> </TD>
</Tr>
</Itemtemplate>
<Footertemplate>
</Table> </div>
</Footertemplate>
</ASP: repeater>
Then, a hidden domain is used to record the ID of each line, so that the server can call
<Input id = "hdnproductid" type = "hidden" value = "0" runat = "server" name = "hdnproductid">
Then Javascript is used to implement the CSS effect.
function repeater_selectrow (row, productid) {var HDN = Document. form1.hdnproductid; HDN. value = productid; If (lastrowselected! = Row) {If (lastrowselected! = NULL) {lastrowselected. style. backgroundcolor = originalcolor; lastrowselected. style. color = 'black' lastrowselected. style. fontweight = 'normal';} originalcolor = row. style. backgroundcolorrow. style. backgroundcolor = 'black' row. style. color = 'white' row. style. fontweight = 'normal' lastrowselected = row ;}< PRE> function repeater_mousehover (ROW) {row. style. cursor = 'hand';}