在Asp.net Gridview中设置列宽 [英] Setting Column Width in Asp.net Gridview

查看:1192
本文介绍了在Asp.net Gridview中设置列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我有一个有5个数据列列的gridview。



我想将所有列的宽度设置为100px。



我是通过列项式样式属性完成的,但是在将数据绑定到gridview之后它根据单元格文本放大了









怎么样我修好了吗?







能帮帮我吗?

Hi,


I have a gridview having 5 databound column.

I want to set all the column''s width to 100px.

I did it via column Item-Style properties, but after binding data to gridview its
enlarging according to the cell text.



How can i fix it?



Can you please help me?

推荐答案

您可以使用 style =white-space:nowrap; overflow:hidden;如果文本大于列,将截断文本宽度。你可以使用 style =overflow:hidden;如果你想要包装你的文字。
You can use style="white-space: nowrap;overflow: hidden;" which will truncate the text if it is larger than column width. You can use style="overflow: hidden;" if you want your text to be wrapped.


这是简单而好的解决方案



< asp:boundfield datafield =BranchNameheadertext =分支名称xmlns:asp =#unknown>

< HeaderStyle Width =300pxHorizo​​ntalAlign =LeftWrap =False>< / HeaderStyle>

< itemstyle width =300horizo​​ntalalign =Leftwrap =False >
It is Easy and ok solution

<asp:boundfield datafield="BranchName" headertext="Branch Name" xmlns:asp="#unknown">
<HeaderStyle Width="300px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>
<itemstyle width="300" horizontalalign="Left" wrap="False">


It will add a tag on every column as

<HeaderStyle Width="100px" />


这篇关于在Asp.net Gridview中设置列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆