J
J055
Hi
I have an overridden InitializePager method in my custom GridView. I use it
to add some page information to the pager row by splitting the table cell.
This works fine until I add either a BoundField or TemplateField where
visible is set to false.
This causes the two Table Cells of the pager row to have incorrect
columnSpans, e.g. where I have 6 columns and one invisible column (total 7)
the pager row will have a left cell with colspan="6" and a right cell with
colspan="4". If I change then visible attribute to true I get left cell with
colspan="3" and a right cell with colspan="4" which is correct.
I have know idea why this happens. When debugging I have found the
InitializePager method is called with columnSpan parameter set to the number
of columns including the invisible one (7).
Please help.
Thanks
Andrew
protected override void InitializePager(GridViewRow row, int columnSpan,
PagedDataSource pagedDataSource)
{
// call the base method first
base.InitializePager(row, columnSpan, pagedDataSource);
// create a new tablecell to contain the new page information
TableCell cell1 = new TableCell();
// divide the pager row in half
int ltSpan = (int)(columnSpan / 2);
int rtSpan = columnSpan - ltSpan;
// add the new label control with the new page info
cell1.Controls.Add(PageInfo(pagedDataSource.DataSourceCount));
// add the new cell to the pager row and apply the ColumnSpan sizes
row.Controls.AddAt(0, cell1);
row.Cells[0].ColumnSpan = ltSpan;
row.Cells[1].ColumnSpan = rtSpan;
// pager buttons are now the right and page info on the left
row.Cells[1].HorizontalAlign = HorizontalAlign.Right;
}
I have an overridden InitializePager method in my custom GridView. I use it
to add some page information to the pager row by splitting the table cell.
This works fine until I add either a BoundField or TemplateField where
visible is set to false.
This causes the two Table Cells of the pager row to have incorrect
columnSpans, e.g. where I have 6 columns and one invisible column (total 7)
the pager row will have a left cell with colspan="6" and a right cell with
colspan="4". If I change then visible attribute to true I get left cell with
colspan="3" and a right cell with colspan="4" which is correct.
I have know idea why this happens. When debugging I have found the
InitializePager method is called with columnSpan parameter set to the number
of columns including the invisible one (7).
Please help.
Thanks
Andrew
protected override void InitializePager(GridViewRow row, int columnSpan,
PagedDataSource pagedDataSource)
{
// call the base method first
base.InitializePager(row, columnSpan, pagedDataSource);
// create a new tablecell to contain the new page information
TableCell cell1 = new TableCell();
// divide the pager row in half
int ltSpan = (int)(columnSpan / 2);
int rtSpan = columnSpan - ltSpan;
// add the new label control with the new page info
cell1.Controls.Add(PageInfo(pagedDataSource.DataSourceCount));
// add the new cell to the pager row and apply the ColumnSpan sizes
row.Controls.AddAt(0, cell1);
row.Cells[0].ColumnSpan = ltSpan;
row.Cells[1].ColumnSpan = rtSpan;
// pager buttons are now the right and page info on the left
row.Cells[1].HorizontalAlign = HorizontalAlign.Right;
}