先说明效果:
当鼠标在GridView的行上划过的时候,页面显示出相应行的内,但是项的内容是非数字的时候,不能显示
代码如下:[code=C#]       
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        string res = e.Row.Cells[0].Text.ToString();
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //当鼠标加载的时候,在页面下方显示详细信息
            e.Row.Attributes.Add("onmouseover", "document.getElementById(\"newsInfo\").innerHTML=" + res + "");
//在客户端动态的显示内容
        }
    }[code]

解决方案 »

  1.   


    e.Row.Attributes.Add("onmouseover", "document.getElementById(\"newsInfo\").innerHTML='" + res + "';"); 
      

  2.   

    newsInfo 是什么? span ?
      

  3.   

    e.Row.Attributes.Add("onmouseover", "document.getElementById(\'newsInfo\').innerHTML=' + res + ';"); 
      

  4.   

    string res = e.Row.Cells[0].Text.ToString()
    改成
    string res = "'" + e.Row.Cells[0].Text.ToString() + "'"
      

  5.   

    为innerHTML赋值你得加上引号啊:
    e.Row.Attributes.Add("onmouseover", "document.getElementById(\"newsInfo\").innerHTML='" + res + "';"); 
    当然用\"也可以:
    e.Row.Attributes.Add("onmouseover", "document.getElementById(\"newsInfo\").innerHTML=\"" + res + "\";"); 
      

  6.   

    问题解决了,为什么不能给分呢?到分有意思吗?Sandy945 
    阿非(想找回编程的感觉~) 
    你的代码我贴上运行了,报错所以……,不过还是谢谢你
      

  7.   

    e.Row.Attributes.Add("onmouseover", "document.getElementById(\"newsInfo\").innerHTML=‘" + res + "’");