围绕数据单元格中的网格视图 [英] Centering the data in a cell in grid view
本文介绍了围绕数据单元格中的网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview,我在运行时动态关联网格视图数据源
I have a gridview and i'm associating the datasource for the grid view dynamically at runtime
我的意思是
gridView2.DataSource = titlesArrayList;
gridView2.DataBind();
和我想在这个网格视图的单元中的数据为中心,现在他们正在左对齐
And i want the data in cells of this grid view to be centered, right now they are left-justified
如果我是通过
<asp:BoundField />
我有这个属性。
ItemStyle-HorizontalAlign="Center"
但我怎么可以访问此属性,如果在GridView动态关联
But how can i access this property if the gridview is associated dynamically
我希望你明白我的问题。
I hope u understand my problem
谢谢期待
推荐答案
编辑:
尝试
foreach (GridViewRow row in GridView1.Rows)
{
foreach (TableCell cell in row.Cells)
{
cell.Attributes.CssStyle["text-align"] = "center";
}
}
这篇关于围绕数据单元格中的网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文