Override text-align on a single GridView column RRS feed

  • Question

  • User239939989 posted

    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?

    Monday, January 12, 2009 5:34 PM

All replies

  • User187056398 posted

    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;
    Monday, January 12, 2009 9:46 PM
  • User-1073204616 posted

    I had the same issue. Thanks Wellens. Your suggestion solved my problem.

    Friday, May 28, 2010 10:11 AM
  • User1939562560 posted

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
                if (e.Row.RowType == DataControlRowType.DataRow)
                    e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;

    Tuesday, September 16, 2014 5:47 AM