GridView +Javascript
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string msg = "alert(";
if (e.Row.RowType == DataControlRowType.DataRow)
{
msg += e.Row.Cells[2].Text.ToString();
msg += ")";
e.Row.Attributes.Add("onclick",msg);
}
}
本来应该在GridView1的栅格点击弹出每行的e.Row.Cells[2].Text..
eg:e.Row.Cells[2].Text="test";
应该结果alert("test");
但是现在的结果是alert(test),竟然把test当成一个变量,当然js报错...不知道为什么?