gridview列内容自动换行的方法
2009-08-25 16:55
344 查看
001-0004 gridview列内容自动换行的方法
在RowCreated事件中添加
e.Row.Cells[6].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
这样则会让你选定的列自动换行了 不过前提是要给列设置宽度
<asp:BoundField DataField="Memo" HeaderText="备注" >
<ItemStyle Width="20%" Wrap="True" />
</asp:BoundField>
前台这样写。 注意: Wrap="True" 啊!
--------------------------------------------------------------------------------------------------------------------
在页面加入属性:style =" word-break :break-all ; word-wrap:break-word " (table或div 等的属性里)
或设置
protected void GridView1_DataRowBound(object o, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//设置要换行的模板列
e.Row.Cells[0].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
e.Row.Cells[1].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
}
}
--------------------------------------------------------------------------------------------------------------------
在GridView的数据绷定中的添加如下事件:
也就是给GridView的每行动态添加上Style的属性和其对应的属性植.
protected void ADCGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//word-break:break-all;
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Attributes.Add("Style", "word-break:break-all;");
}
}
}
--------------------------------------------------------------------------------------------------------------------
GridView强制换行与自动换行
在PageLoad中加入如下代码:
//正常换行
GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
//下面这行是自动换行
GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
if (!IsPostBack)
{
bind();//调用数据绑定即可
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/czw_mr/archive/2009/05/06/4155484.aspx
在RowCreated事件中添加
e.Row.Cells[6].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
这样则会让你选定的列自动换行了 不过前提是要给列设置宽度
<asp:BoundField DataField="Memo" HeaderText="备注" >
<ItemStyle Width="20%" Wrap="True" />
</asp:BoundField>
前台这样写。 注意: Wrap="True" 啊!
--------------------------------------------------------------------------------------------------------------------
在页面加入属性:style =" word-break :break-all ; word-wrap:break-word " (table或div 等的属性里)
或设置
protected void GridView1_DataRowBound(object o, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//设置要换行的模板列
e.Row.Cells[0].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
e.Row.Cells[1].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
}
}
--------------------------------------------------------------------------------------------------------------------
在GridView的数据绷定中的添加如下事件:
也就是给GridView的每行动态添加上Style的属性和其对应的属性植.
protected void ADCGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//word-break:break-all;
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Attributes.Add("Style", "word-break:break-all;");
}
}
}
--------------------------------------------------------------------------------------------------------------------
GridView强制换行与自动换行
在PageLoad中加入如下代码:
//正常换行
GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
//下面这行是自动换行
GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
if (!IsPostBack)
{
bind();//调用数据绑定即可
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/czw_mr/archive/2009/05/06/4155484.aspx
相关文章推荐
- gridview列内容自动换行的方法
- 001-0004 gridview列内容自动换行的方法
- 行多出的内容不自动换行解决方法
- CSS让网页(Li)中的内容自动换行的实现方法
- QTableView中文本根据内容自动换行的简单方法
- ASP.NET GridView中文本内容无法换行(自动换行/正常换行)
- GridView中的内容过长时自动换行
- textarea标签内容为(英文或数字不自动换行)的解决方法
- ASP.NET GridView中文本内容无法换行(自动换行/正常换行)
- C#下 ASP.NET 2.0中禁止GridView的内容自动换行 (测试有效!!)
- ASP.NET GridView中文本内容无法换行(自动换行/正常换行)
- GridView 内容自动换行 简单记录
- word-break:break-all和word-wrap:break-word都是能使其容器如DIV的内容自动换行。
- html表格内容自动换行
- input框自动填充内容背景颜色为黄色解决方法
- CSS中DIV只出现竖向滚动条且内容自动换行
- textarea 中的内容自动换行
- 【收集】td中内容自动换行
- android中ListView中嵌套GridView并且把GridView当中的内容全部显示出来的方法
- 转载:table单元格内容自动换行