SPGridView字段(单元格)换行


前台:

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


你可能感兴趣的:(GridView)