您的位置:首页 > 编程语言 > ASP

解决ASP.net的GridView自动换行的问题

2009-07-13 08:38 609 查看
 





如上图所示,当指定了不允许换行时仍会有日期格式的列自动换行,解决方法如下:

protected void GVData_RowDataBound(object sender, GridViewRowEventArgs e)
    {

//如果是绑定数据行
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

//指定某一列不允许换行

e.Row.Cells[8].Wrap = false;

//指定某一列允许换行

//e.Row.Cells[8].Wrap = true;

}   //设置所有列不允许换行
            GVData.Attributes.Add("style", "word-break:keep-all;word-wrap:false");

//设置所有列自动换行
           //GVData.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");

}

http://hi.baidu.com/jonesvale/blog/item/a861bd7fcc6546310dd7da05.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  asp.net object