您的位置:首页 > 编程语言 > ASP

asp.net操作Gridview单元格

2008-11-19 16:02 274 查看
操作Gridview单元格
可以在Gridview的RowDataBound事件中获取,参照下面的代码

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

foreach (TableCell cell in e.Row.Cells)

{

//单击鼠标可以将单元格中的内容复制到剪切板

cell.Attributes.Add("onclick", "window.clipboardData.setData('Text', this.innerText);");

//鼠标移入可以设置单元格字体颜色

cell.Attributes.Add("onmouseover", "this.style.color='red'");

//鼠标移开,取消单元格字体颜色设置

cell.Attributes.Add("onmouseout", "this.style.color=''");

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: