By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,972 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,972 IT Pros & Developers. It's quick & easy.

Setting pager-style in DataGrid

P: n/a
Hi all,

is it possible to set a separate style in a datagrid pager for the selected
page to make it more clear for the user which page is selected?
For example: page 3 is selected out of the 8 possible pages and the number 3
is then displayed in bold and with an alternate color.

There's a pager style but there is no setting for the selected page.

TIA
Friso Wiskerke
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Frisko,

you can achieve the same by modifying the pager properties in the DataGrid's
ItemCreated event.

Add the following event handler in the InitializeComponent() method -

this.DataGrid1.ItemCreated += new
System.Web.UI.WebControls.DataGridItemEventHandler (this.DataGrid1_ItemCreated);

The DataGrid ItemCreated method code will be -

private void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs e)
{
if ( e.Item.ItemType == ListItemType.Pager)
{
TableCell Pager = (TableCell) e.Item.Controls[0];
for(int i = 0;i < Pager.Controls.Count ; i++ )
{
object pageNumbers = Pager.Controls[i];
if (pageNumbers.GetType().Name == "DataGridLinkButton")
{
LinkButton lbt = (LinkButton) pageNumbers;
lbt.ForeColor = System.Drawing.Color.Gray;
}
else if(pageNumbers.GetType().Name == "Label")
{
Label lbl = (Label) pageNumbers;
lbl.ForeColor = System.Drawing.Color.Black;
lbl.Font.Bold = true;
}
}
}
}

HTH.

"Friso Wiskerke" wrote:
Hi all,

is it possible to set a separate style in a datagrid pager for the selected
page to make it more clear for the user which page is selected?
For example: page 3 is selected out of the 8 possible pages and the number 3
is then displayed in bold and with an alternate color.

There's a pager style but there is no setting for the selected page.

TIA
Friso Wiskerke

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.