L
Larry Viezel
I would like to add controls to the pagerstyle item in my datagrid.
Simple enough:
private void DataGrid_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Pager)
{
//retrieve the pager cell
TableCell PagerCell = (TableCell)e.Item.Controls[0];
//format the column span of PagerCell
int TCS = PagerCell.ColumnSpan; //total column span
PagerCell.ColumnSpan = Convert.ToInt32(Math.Floor(TCS / 2));
//Add the new cell
e.Item.Controls.AddAt(0, new
System.Web.UI.WebControls.TableCell());
TableCell NewCell = (TableCell)e.Item.Controls[0];
//format the new cell
NewCell.ColumnSpan = TotalColumnSpan - PagerCell.ColumnSpan;
NewCell.HorizontalAlign = HorizontalAlign.Left;
//Code to add controls to the new cell goes here...
}
}
I can add more new cells as needed to add even more controls that my
wacky designers want. The trouble I am having is that using the methods
I have, I am can only add as many controls as there are columns I am
displaying from the grid's datasource before I mess up the display. I'd
also be bound to the width and position of these columns. The simple
solution is to use a nested table. But I don't quite know how to
program that around the already existing and defined PagerCell.
Is there an easy way to add a table in PagerCell and then move the
current contents of PagerCell (the previous and next linkbutton
controls) into a cell in that table?
Any help would be appreciated.
Larry.
Simple enough:
private void DataGrid_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Pager)
{
//retrieve the pager cell
TableCell PagerCell = (TableCell)e.Item.Controls[0];
//format the column span of PagerCell
int TCS = PagerCell.ColumnSpan; //total column span
PagerCell.ColumnSpan = Convert.ToInt32(Math.Floor(TCS / 2));
//Add the new cell
e.Item.Controls.AddAt(0, new
System.Web.UI.WebControls.TableCell());
TableCell NewCell = (TableCell)e.Item.Controls[0];
//format the new cell
NewCell.ColumnSpan = TotalColumnSpan - PagerCell.ColumnSpan;
NewCell.HorizontalAlign = HorizontalAlign.Left;
//Code to add controls to the new cell goes here...
}
}
I can add more new cells as needed to add even more controls that my
wacky designers want. The trouble I am having is that using the methods
I have, I am can only add as many controls as there are columns I am
displaying from the grid's datasource before I mess up the display. I'd
also be bound to the width and position of these columns. The simple
solution is to use a nested table. But I don't quite know how to
program that around the already existing and defined PagerCell.
Is there an easy way to add a table in PagerCell and then move the
current contents of PagerCell (the previous and next linkbutton
controls) into a cell in that table?
Any help would be appreciated.
Larry.