T
Tim_Mac
hi,
i have an extended Datagrid class, it does nice automatic things like
providing an excel export feature, sorting, paging etc.
i would like it to automatically right-align any numeric columns, but i have
run into a problem where the 'DataGrid.Columns' collection is empty when the
DataGrid is using AutoGenerateColumns, and i am unable to set the
ItemStyle.HorizontalAlign property because there are no DataGridColumns to
access. can anyone think of a way to style the column, without resorting to
declaring every column in the ASPX?
here is the code i use in protected override void Render(...)
// align the numeric columns
int col=0;
if(this.AutoGenerateColumns)
{
// iterate over dataview table columns
foreach(DataColumn dc in this.dv.Table.Columns)
{
if(Regex.IsMatch(dc.DataType.Name, "Decimal|Double|Int16|Int32|Int64"))
this.Columns[col].ItemStyle.HorizontalAlign =
this.AutoAlignNumberColumns;
col++;
}
}
very grateful for any suggestions. if i use declared columns it does work
correctly.
thanks
tim
i have an extended Datagrid class, it does nice automatic things like
providing an excel export feature, sorting, paging etc.
i would like it to automatically right-align any numeric columns, but i have
run into a problem where the 'DataGrid.Columns' collection is empty when the
DataGrid is using AutoGenerateColumns, and i am unable to set the
ItemStyle.HorizontalAlign property because there are no DataGridColumns to
access. can anyone think of a way to style the column, without resorting to
declaring every column in the ASPX?
here is the code i use in protected override void Render(...)
// align the numeric columns
int col=0;
if(this.AutoGenerateColumns)
{
// iterate over dataview table columns
foreach(DataColumn dc in this.dv.Table.Columns)
{
if(Regex.IsMatch(dc.DataType.Name, "Decimal|Double|Int16|Int32|Int64"))
this.Columns[col].ItemStyle.HorizontalAlign =
this.AutoAlignNumberColumns;
col++;
}
}
very grateful for any suggestions. if i use declared columns it does work
correctly.
thanks
tim