Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/1/30 1:28:48
gridview超出长度用..代替,提示显示详细信息_[Asp.Net教程]

gridview超出长度用..代替,提示显示详细信息_[Asp.Net教程]
for (int i = 0; i < e.Row.Cells.Count; i++)//获取总列数
{
//如果是数据行则添加title
if (e.Row.RowType == DataControlRowType.DataRow)
{//设置title为gridview的head的text
e.Row.Cells[i].Attributes.Add("title", GrvNew.HeaderRow.Cells[i].Text.ToString().Trim());
}
}
}
if (e.Row.RowIndex > -1)
{
string tmp =((HyperLink) e.Row.FindControl("HypLinkTitle")).Text;
if (tmp.Length > 3)
{
((HyperLink)e.Row.FindControl("HypLinkTitle")).Text = tmp.Substring(0, 3) + "…";
((HyperLink)e.Row.FindControl("HypLinkTitle")).Attributes.Add("title", tmp);//以tooptip的方式显示全部内容
}
}

实现gridview中把字段超出范围的用...代替 但前台文本提示效果需显示详细信息,效果很不错!


If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759