给Gridview添加RowDataBound事件。触发事件时,给每一列添加title属性。title属性为HTML5中的属性
protected void exGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < e.Row.Cells.Count; i++)//获取总列数
{
e.Row.Cells[i].Attributes.Add("title", e.Row.Cells[i].Text.Trim());
e.Row.Cells[i].Attributes.Add("style", "white-space: nowrap;width:50px;overflow:hidden");
}
}
给Gridview 加cssclass:
table-layout:fixed;
更香