SPGridview标题列对齐

时间:2011-12-14 20:13:17

标签: asp.net formatting alignment boundfield spgridview

我在后面的代码中创建了网格。 网格包含描述,语言等列。问题是这两列的headertext没有左对齐。网格内的数据已经离开了。

我是否缺少任何指定标题列文本左对齐的内容。

感谢。

                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();

1 个答案:

答案 0 :(得分:1)

您还必须设置标题的对齐方式。

boundField.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left;