gridview如何将超长字符串自动截断,然后用省略号代替吗?知道的话把详细的步骤说明一下,谢谢
1个回答
展开全部
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Length >10 ? "大于10" : "小于10";
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Length >10 ? "大于10" : "小于10";
}
更多追问追答
追问
那怎么用省略号代替呢?
追答
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Length > 10 ? e.Row.Cells[0].Text.Substring(0, 10) + "..." : e.Row.Cells[0].Text;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询