网格视图样式 [英] Grid View style

查看:87
本文介绍了网格视图样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个显示一列的网格视图控件,我想更改该列的样式.我希望将其文本对齐设置为中心.我尝试将其放在adiv中,但它发生在整个网格中.

我该怎么做?

谢谢

Hi all,

I have a grid view control that displays one column and I want to change the style of that column. I want its text-align to be set to the center. I tried to put it in adiv but it occurred in the whole grid.

How can I make that?

Thanks

推荐答案


您可以使用GridView ItemStyle属性来对齐文本.对于其中的GridView BoundField或TemplateField作为名为ItemStyle HorizontalAlign的属性,您可以编写ItemStyle-HorizontalAlign="Center"
例如,
Hi,
You can use GridView ItemStyle property to align your text. For GridView BoundField or TemplateField there in as property called ItemStyle HorizontalAlign, You can write ItemStyle-HorizontalAlign="Center"
As for example,
<asp:BoundField ItemStyle-HorizontalAlign="Center" DataField="ProductID" HeaderText="ProductID" ReadOnly="True"
                              SortExpression="ProductID" />


希望对您有所帮助!


Hope this will help !


请参阅此处:
See here:
GridView Examples for ASP.NET 2.0: Formatting the GridView


[ ^ ].

不是最新的,但是它会带你去.


[^].

Not bang up to date but it''ll get you going.


两种方法,
1.使用索引/列名从网格中查找列,然后应用特定于此的CSS.
2.您可以使用datagrid的ItemDatabound或gridview的RowDatabound进入列/单元格级别,然后在其上应用CSS.看看本文 [
Two ways,
1. Find the column using index/column-name from the grid and then apply css specific to this.
2. You can go to column/cell level using datagrid''s ItemDatabound or gridview''s RowDatabound and apply css at then. Have a look at this article[^] for the same.


这篇关于网格视图样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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