我喜欢尽可能回答我自己的问题,以便将来搜索该主题的用户找到答案。
我找不到直接做我想做的事的方法。但是我发现如果我自己定义列,我可以更改属性。在此示例中,我想将列数据居中。像这样的东西。
BoundField bdfRaisedDate = new BoundField();
clsUtilities.SetBoundFieldCenter(ref bdfRaisedDate, "RaisedDateShort", "Opened", "RaisedDate");
grdIssues.Columns.Add(bdfRaisedDate);
grdIssues.DataSource = mdtIssues;
grdIssues.DataBind();
public static void SetBoundFieldCenter(ref BoundField bdfAny, string pDataField, string pHeadingValue, string pSortExpression)
{
bdfAny.DataField = pDataField;
bdfAny.HeaderText = pHeadingValue;
bdfAny.SortExpression = pSortExpression;
bdfAny.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
bdfAny.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
}