代码改变世界

SPGridView字段(单元格)换行

  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);
            }

    }
复制代码
复制代码
代码
    public string KeepPre(string html)
    {
        
if (string.IsNullOrEmpty(html))
        {
            
return html;
        }
        html 
= html.Replace("\n""<br/>");
        
return html;
    }
复制代码


努力加载评论中...
点击右上角即可分享
微信分享提示