SPGridView字段(单元格)换行
2010-04-18 00:11 Leason Li 阅读(331) 评论(0) 编辑 收藏 举报前台:
<asp:BoundField DataField="Integral" HeaderText="积分" />
后台:
dr["CompanyName"] += dt.Rows[j]["CompanyName"].ToString() + "\n";

protected void SPGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[1].Text = KeepPre(e.Row.Cells[1].Text);
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[1].Text = KeepPre(e.Row.Cells[1].Text);
}
}

public string KeepPre(string html)
{
if (string.IsNullOrEmpty(html))
{
return html;
}
html = html.Replace("\n", "<br/>");
return html;
}
{
if (string.IsNullOrEmpty(html))
{
return html;
}
html = html.Replace("\n", "<br/>");
return html;
}
作者:leening_li
出处:http://www.cnblogs.com/leening/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步