I have a css friendly grid view that defaults to text-align=left; for all columns. I have a few numerical columns that I would like to override text-align property to be right align. How do I do this?
I've never used a CSS friendly grid view but this might work:
protected void GridView1_DataBound(object sender, EventArgs e) { GridView1.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Right; }
I had the same issue. Thanks Wellens. Your suggestion solved my problem.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center; } }