Customizing PagerStyle in a datagrid

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top