SPGridView字段(单元格)换行
2010-04-18 00:11 Leason Li 阅读(330) 评论(0) 编辑 收藏 举报前台:
<asp:BoundField DataField="Integral" HeaderText="积分" />
后台:
dr["CompanyName"] += dt.Rows[j]["CompanyName"].ToString() + "\n";
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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);
}
}
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。