GridView标题行换行之我见 (转)

本文介绍了一种在ASP.NET中使用GridView时解决中文标题换行问题的方法。通过在RowDataBound事件中添加代码,可以有效地实现中文标题的正常换行显示,解决了CSS方法仅适用于英文的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1、不换行:
word-break:keep-all;word-wrap:normal
2、换行:
word-break:break-all;word-wrap:break-word
以上的换行只支持英文,当标题中包含有中文时并不好用。
3、如果标题中含有中文的,只能在GridView的RowDataBound事件中添加代码,如下:
if (e.Row.RowType == DataControlRowType.Header)
{
    e.Row.Cells[
0].Text = "<nobr>操作用户</nobr>";
            e.Row.Cells[
1].Text = "<nobr>批次名称</nobr>";
            e.Row.Cells[
2].Text = "<nobr>文件名称</nobr>";
            e.Row.Cells[
3].Text = "<nobr>档案类型</nobr>";
            e.Row.Cells[
4].Text = "<nobr>字段名称</nobr>";
            e.Row.Cells[
5].Text = "<nobr>字段值</nobr>";
            e.Row.Cells[
6].Text = "<nobr>字段长度</nobr>";
            e.Row.Cells[
7].Text = "<nobr>所在流程</nobr>";
            e.Row.Cells[
8].Text = "<nobr>开始时间</nobr>";
            e.Row.Cells[
9].Text = "<nobr>结束时间</nobr>";
            e.Row.Cells[
10].Text = "<nobr>录入版本</nobr>";            

 

http://www.cnblogs.com/gonghui/articles/1661198.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值