Question

I have grid that gets created in the code behind. Grid has columns like Description, Language. Issue is the headertext for these 2 columns is not getting left aligned. The data within the grid have left alignement.

Is there anything I am missing to specify left alignment for the header column text.

Thanks.

                SPGridView gridView = new SPGridView();
                gridView.AutoGenerateColumns = false;

                // create the bound fields
                SPBoundField boundField;
                boundField = new SPBoundField();
                boundField.HeaderText = "Description";
                boundField.DataField = "Description";
                boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                boundField.ItemStyle.Wrap = false;
                gridView.Columns.Add(boundField); 


                boundField = new SPBoundField();
                boundField.HeaderText = "Language";
                boundField.DataField = "Language";
                boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                gridView.Columns.Add(boundField);

                gridView.DataSource = dt.DefaultView;
                gridView.DataBind();
Était-ce utile?

La solution

You have to set the alignment of the Header as well.

boundField.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top