GridView欄位的寬度

ybsl97 2009-05-13 11:53:27
我的Gridview有40個欄位,如何讓Gridview某一欄的寬度固定下來,比如100px?
...全文
379 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2009-05-13
  • 打赏
  • 举报
回复
GridView.Attributes.Add( "style ", "table-layout:fixed ")
参考
takako_mu 2009-05-13
  • 打赏
  • 举报
回复
用DIV很好.
mengxj85 2009-05-13
  • 打赏
  • 举报
回复
二楼的方法也不错
或者用模板列

<ItemTemplate>
<div style="word-break:break-all; width:100px;"><%# Bind("colName") %>
</div>
</ItemTemplate>
qq904492758 2009-05-13
  • 打赏
  • 举报
回复
up
takako_mu 2009-05-13
  • 打赏
  • 举报
回复
如果只是簡單的7、8個欄位,簡單的用<ItemStyle Width="100px" />還可以,
如果是40個欄位已經不行了。
mengxj85 2009-05-13
  • 打赏
  • 举报
回复
<ItemStyle Width="100px" />
zhulong1111 2009-05-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 takako_mu 的回复:]
在GridView1_RowDataBound事件中添加

C# code
e.Row.Cells(i).Width = 100
e.Row.Cells(i).Attributes.Add("style", "word-break :break-all ; word-wrap:break-word")
[/Quote]up
zhulong1111 2009-05-13
  • 打赏
  • 举报
回复
up
takako_mu 2009-05-13
  • 打赏
  • 举报
回复
在GridView1_RowDataBound事件中添加

e.Row.Cells(i).Width = 100
e.Row.Cells(i).Attributes.Add("style", "word-break :break-all ; word-wrap:break-word")
takako_mu 2009-05-13
  • 打赏
  • 举报
回复
sf,up

62,248

社区成员

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

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

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

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