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.