Highlight and move rows in the gridview under Asp.net 2.0

Source: Internet
Author: User
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';} 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.