1. 程式人生 > >為GridView每個單元格滑鼠移上去顯示div

為GridView每個單元格滑鼠移上去顯示div

{

                
string table ="<table cellspacing='0' rules='all' bordercolorlight='#b4b1b1' bordercolordark='#ffffff' border='1'><tr class='title'><td>資料來源</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='成考']/Data/Year");
                
//xmlDoc.SelectSingleNode("/Datas/notes[@id='" + i + "']/Source[@Desc='成考']/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()");
            }