dsfasdfadf dsfasdfadf - 6 months ago 27
ASP.NET (C#) Question

Centering the data in a cell in grid view

I have a gridview and i'm associating the datasource for the grid view dynamically at runtime

I mean

gridView2.DataSource = titlesArrayList;

And i want the data in cells of this grid view to be centered, right now they are left-justified

If i was associating data through

<asp:BoundField />

I have this property


But how can i access this property if the gridview is associated dynamically

I hope u understand my problem

Thanks in anticipation




        foreach (GridViewRow  row in GridView1.Rows)
            foreach (TableCell cell in row.Cells)
                cell.Attributes.CssStyle["text-align"] = "center";