GridView绑定数据的单元格的换行问题。

smartboy986 2008-09-11 02:22:38
在gridview上的一个单元格,显示的数据是a_b_c
怎样可以分割成a b c 并在一个单元格里换行显示?
...全文
268 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
rachel_ll 2011-04-06
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 smartboy986 的回复:]

引用 7 楼 cmaisyd 的回复:
<asp:Label runat="server" ID="Label1" Text=' <%# Eval("字段名").replace("_"," <br />") %>' />

还要注意该单元格的编码是否允许HTML编码


gridview里的单元格单元格的编码是否允许HTML编码?
这个如何识别?
[/Quote]

我也想知道
greatverve 2008-09-11
  • 打赏
  • 举报
回复
学到了.
smartboy986 2008-09-11
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 cmaisyd 的回复:]
<asp:Label runat="server" ID="Label1" Text=' <%# Eval("字段名").replace("_"," <br />") %>' />

还要注意该单元格的编码是否允许HTML编码
[/Quote]

gridview里的单元格单元格的编码是否允许HTML编码?
这个如何识别?
cmaisyd 2008-09-11
  • 打赏
  • 举报
回复
<asp:Label runat="server" ID="Label1" Text=' <%# Eval("字段名").replace("_","<br />") %>' />

还要注意该单元格的编码是否允许HTML编码
tangjinzn 2008-09-11
  • 打赏
  • 举报
回复
在页面加入属性:style =" word-break :break-all ;word-wrap:break-word"(table或div 等的属性里)
smartboy986 2008-09-11
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 tangjinzn 的回复:]
用replace方法

Replace("_"," ");

就可以把下划线换成空格
[/Quote]

然后如何执行换行的操作 ?
smartboy986 2008-09-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 namhyuk 的回复:]
<TemplateField>
<ItemTemplate>
<asp:Label runat="server" ID="Label1" Text=' <%# GetSplitted(Eval("字段名")) %>' />

....


C#

public string GetSplitted(obj str)
{
string[] strArray = str.Split('_');
string result = string.Empty;
for(int i = 0; i < result.Length; i++)
{
if(i < result.Length -1)
result += strArray[i] + " "…
[/Quote]

这个是分隔字符串的操作,换行操作呢?
tangjinzn 2008-09-11
  • 打赏
  • 举报
回复
用replace方法

Replace("_"," ");

就可以把下划线换成空格
a2068879 2008-09-11
  • 打赏
  • 举报
回复
GridView怎么设置内边框的颜色呢
namhyuk 2008-09-11
  • 打赏
  • 举报
回复
<TemplateField>
<ItemTemplate>
<asp:Label runat="server" ID="Label1" Text='<%# GetSplitted(Eval("字段名")) %>' />

....


C#

public string GetSplitted(obj str)
{
string[] strArray = str.Split('_');
string result = string.Empty;
for(int i = 0; i < result.Length; i++)
{
if(i < result.Length -1)
result += strArray[i] + " ";
else
result += strArray[i];
}
return result;
}

没试过.

62,040

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧