我设置的GridView中的这列宽度是 416 px ,可是如果这列的内容很长而且文字中间没有空格的话,他就不会自动换行,还是会把 416px 宽度的列给撑大??
怎么解决呢,怎么能让此列中的内容不把列撑大,到了416px长度就自动换行呢``??<asp:BoundField DataField="IO_Re" HeaderText="备注" ItemStyle-Width="416px" />
怎么解决呢,怎么能让此列中的内容不把列撑大,到了416px长度就自动换行呢``??<asp:BoundField DataField="IO_Re" HeaderText="备注" ItemStyle-Width="416px" />
解决方案 »
- 求大家幫我看看這個MVC代碼,實在沒看懂它怎麼操作數據庫的Movies表的
- 急求ASP.NET,C#.net高手解决~!
- 本来有一个网站用asp开发的,登陆时用cookies保存了客户信息,后来有一模块用.net 进行了开发,我想用.net 用登陆保存的cookies,但是不能
- DataGrid分页显示问题
- 怎么设置点击TreeView触发javascript事件啊?
- 【如何判断访问网站的主机是不是就是该服务器?】
- 删除datagrid中的选中的记录
- asp.net用localhost调试弹出google页面,而用127.0.0.1则可以
- 我想问一下.net连接oralce怎么做?
- 请问用DataReader怎么读取列的名字?
- 谁帮忙写个正确的IP正则。
- 求助高手:为什么我的递归会出现两次?
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//这里不知道什么意思,大概是行的状态(是不是可以编辑)
if (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)
|| e.Row.RowState == DataControlRowState.Edit)
{
//定义一个文本筐
TextBox curText;
//有多少列,循环几次
for (int i = 0; i < e.Row.Cells.Count; i++)
{ if (e.Row.Cells[i].Controls.Count != 0)
{ curText = e.Row.Cells[i].Controls[0] as TextBox; if (curText != null)
{ curText.Width = Unit.Pixel(70);
}
}
}
} }
要不你试试这样
<asp:BoundField DataField="processdate" HeaderText="處 理 時 間" ReadOnly="True">
<ItemStyle Width="50px" />
http://www.cnblogs.com/cnaspnet/archive/2008/09/27/1300363.html
{
//这里不知道什么意思,大概是行的状态(是不是可以编辑)
if (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)
|| e.Row.RowState == DataControlRowState.Edit)
{
//定义一个文本筐
TextBox curText;
//有多少列,循环几次
for (int i = 0; i < e.Row.Cells.Count; i++)
{ if (e.Row.Cells[i].Controls.Count != 0)
{
e.Row.Cells[6].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
}
}
}
}
中间没有一个空格,他就不会换行,会把单元格撑大`~!!怎么办呢??
改成模板列,将Label替换成TextBox,设置TextBox的背景色,去掉边框,设置成只读,
效果和Label一样,不会撑大了!!
GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
//自动换行
GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
body { word-wrap: break-word;
word-break: break-all;
}
正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
html
<div id="wrap">正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义</div>
css
#wrap{white-space:normal; width:200px; }1.(IE浏览器)连续的英文字符和阿拉伯数字,使用word-wrap : break-word ;或者word-break:break-all;实现强制断行#wrap{word-break:break-all; width:200px;}
或者
#wrap{word-wrap:break-word; width:200px;}<div id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>效果:可以实现换行2.(Firefox浏览器)连续的英文字符和阿拉伯数字的断行,Firefox的所有版本的没有解决这个问题,我们只有让超出边界的字符隐藏或者,给容器添加滚动条#wrap{word-break:break-all; width:200px; overflow:auto;}<div id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111</div>效果:容器正常,内容隐藏对于table1. (IE浏览器)使用 table-layout:fixed;强制table的宽度,多余内容隐藏<table style="table-layout:fixed" width="200">
<tr>
<td>abcdefghigklmnopqrstuvwxyz1234567890ssssssssssssss
</td>
</tr>
</table>效果:隐藏多余内容2.(IE浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word-break : break-all;或者word-wrap : break-word ;换行<table width="200" style="table-layout:fixed;">
<tr>
<td width="25%" style="word-break : break-all; ">abcdefghigklmnopqrstuvwxyz 1234567890
</td>
<td style="word-wrap : break-word ;">abcdefghigklmnopqrstuvwxyz 1234567890
</td>
</tr>
</table>效果:可以换行3. (IE浏览器)在td,th中嵌套div,p等采用上面提到的div,p的换行方法4.(Firefox浏览器)使用 table-layout:fixed;强制table的宽度,内层td,th采用word- break : break-all;或者word-wrap : break-word ;换行,使用overflow:hidden;隐藏超出内容,这里overflow:auto;无法起作用<table style="table-layout:fixed" width="200">
<tr>
<td width="25%" style="word-break : break-all; overflow:hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>
<td width="75%" style="word-wrap : break-word; overflow:hidden; ">abcdefghigklmnopqrstuvwxyz1234567890</td>
</tr>
</table>效果:隐藏多于内容5.(Firefox浏览器) 在td,th中嵌套div,p等采用上面提到的对付Firefox的方法