Move the mouse of each cell in the gridview to display the DIV

Source: Internet
Author: User

Content in the rowbound event of the gridview

Protected void gridview1_rowdatabound (Object sender, gridviewroweventargs E)
...{
If (E. Row. rowtype = datacontrolrowtype. datarow)
...{
// Dataset DS = new dataset ();

For (INT I = 0; I <E. Row. cells. Count; I ++)
...{

String table = "<Table cellspacing = '0' rules = 'all' bordercolorlight = '# b4b1b1 'bordercolordark =' # ffffff' border = '1'> <tr class = 'title '> <TD> data source </TD> <TD> "+ gridview1.columns [I]. headertext. tostring () + "</TD> </tr> ";
Xmldocument xmldoc = new xmldocument ();
Xmldoc. loadxml (lbhiddengrid. Text );
// Xmldoc. selectsinglenode ("/datas/Notes [@ ID = '" + I + "']/source [@ DESC = 'testing']/data/year ");
// Xmldoc. selectsinglenode ("/datas/Notes [@ ID = '" + I + "']/source [@ DESC = 'testing']/data/year "). firstchild. value
Foreach (xmlnode childnode in xmldoc. selectsinglenode ("/datas/Notes [@ ID = '" + E. Row. rowindex. tostring () + "']")
...{
// Xmlnode childnode = xmldoc. selectsinglenode ("/datas/Notes [@ ID = '" + E. Row. rowindex. tostring () + "']");
// For (Int J = 0; j <xmldoc. selectsinglenode ("/datas/Notes [@ ID = '" + E. row. rowindex. tostring () + "']"). childnodes. count; j ++)
//{

Table + = "<tr> <TD> ";
String name = childnode. Attributes. getnameditem ("DESC"). innertext;
Table + = Name + "</TD> <TD> ";
String value = childnode. selectsinglenode ("Data/" + (boundfield) (gridview1.columns [I]). datafield). innertext;
Table + = value + "</TD> </tr> ";
// Childnode. selectsinglenode ("/data /");
// Ds. readxml (xmlreader. Create (new system. Io. stringreader (childnode. firstchild. outerxml )));
//}
}
Table + = "</table> ";
// String Ss = server. htmlencode (table );
E. Row. cells [I]. Attributes. Add ("onmouseover", "showdivbycs (" "+ Table + "")");
E. Row. cells [I]. Attributes. Add ("onmouseout", "remove ()");
}
}
}

Content in Javascript

// Display the DIV when the cursor passes
Function showdivbycs (table )...{

// Table = table. Replace ("& amp ;","&");
// Table = table. Replace ("& gt;", "> ");
// Table = table. Replace ("& lt;", "<");
// Table = table. Replace ("& quot ;",""");
// Table = table. Replace ("& apos ;","'");

VaR x = Window. event. X;
Var y = Window. event. Y;
VaR show = Document. getelementbyid ("showinfo ");
Show. style. Visibility = "visible ";
Show. style. Top = y;
Show. style. Left = X;
Show. style. Background = "# FFFF00 ";

// Read XML
Document. getelementbyid ("SP"). innerhtml = table;

// Div follows the mouse
Document. onmousemove = movetomouseloc;

}

// When the mouse moves, the DIV follows
Function movetomouseloc (E)
...{
X = Window. event. X;
Y = Window. event. Y;
VaR show = Document. getelementbyid ("showinfo ");
Show. style. Left = X;
Show. style. Top = y;
Return true;
}

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.