Databound event instance of gridview (C #)

Source: Internet
Author: User

Many new users are not familiar with the databound event of the gridview. Today I will cover up an instance and hope to help you!
This is an example of adding a binding effect to the gridview. highlight each row and add a jump event.
First, let's take a look.Code:

1 Protected   Void Gv_testcombinationlist_rowdatabound ( Object Sender, gridviewroweventargs E)
2 {
3 Datarowview View = E. Row. dataitem As Datarowview; // Define a datarowview instance
4 If (View ! =   Null )
5 {
6 E. Row. Attributes. Add ( " Onmouseover " , " This. style. Color = '# ff8105' " );
7 E. Row. Attributes. Add ( " Style " , " Cursor: Hand " );
8 E. Row. Attributes. Add ( " Onmouseout " , " This. style. Color = 'black' " ); // Add attributes for each row
9 For ( Int I =   0 ; I < E. Row. cells. Count; I ++ )
10 {
11 String URL = Rule. getmodulepage (m_moduleid, modulepageenum. testcombinationdetail) +   " ? Id = "   + View [ " Projectid " ]. Tostring () +   " & Testid = "   + View [ " Testid " ]. Tostring (); // Obtain the link address through the method
12 E. Row. cells [I]. Attributes. Add ( " Onclick " , " Self. Location =' "   + URL +   " ' " ); // Add jump Property
13 }
14 }
15 }

A simple small example: as long as you have data in the gridview, the above Code can make them have the effect of highlighting and redirecting. I hope you can proceed further on this basis.
If you have any questions, leave me a message.

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.