Chuck,
That would be great if you would post it here or email me a copy.
Kyle
-----Original Message-----
From: Feduke Cntr Charles R [mailto:FedukeCR@m...]
Sent: Wednesday, May 15, 2002 10:41 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: Headerstyle and Pagerstyle
Frode,
You can get finer control over a DataGrid by creating a class
that
inherits it, and then overrides the OnItemCreated event (and you can
call
base.OnItemCreated for any items that are created that you don't want to
write code for, i.e. for each row). Here's an example from the grid I
use
(original source comes from a MS Press "Designing ASP and ADO .NET
Solutions" or something like that):
---
// basically you make a *.cs file and do:
// public class MyGrid : System.Web.UI.WebControls.DataGrid
public virtual void OnItemCreated(Object sender, DataGridItemEventArgs
e)
{
// Get the newly created item
ListItemType itemType =3D e.Item.ItemType;
// PAGER
if (itemType =3D=3D ListItemType.Pager)
{
TableCell pager =3D (TableCell) e.Item.Controls[0];
Object o =3D null;
// Enumerates all the items in the pager...
for (int i =3D 0; i < pager.Controls.Count; i +=3D 2)
{
o =3D pager.Controls[i];
if (o is LinkButton)
{
LinkButton h =3D (LinkButton) o;
h.Text =3D "[ " + h.Text + " ]";
h.CssClass =3D PagerLinksCssClass;
}
else
{
Label l =3D (Label) o;
l.Text =3D "Page " + l.Text;
if (PagerCurrentPageCssClass =3D=3D "")
{
l.ForeColor =3D Color.White;
l.Font.Bold =3D true;
}
else
l.CssClass =3D
PagerCurrentPageCssClass;
}
}
// add the last page link
if (CurrentPageIndex !=3D PageCount - 1)
{
LinkButton p =3D new LinkButton();
p.Text =3D "[ Last ]";
p.ForeColor =3D PagerStyle.ForeColor;
p.CssClass =3D PagerLinksCssClass;
p.Command +=3D LastPage;
System.Web.UI.WebControls.Literal space =3D new
System.Web.UI.WebControls.Literal();
space.Text =3D " ";
pager.Controls.Add(space);
pager.Controls.Add(p);
}
}
// HEADER
if (itemType =3D=3D ListItemType.Header)
{
for (int i=3D0; i<Columns.Count; i++)
{
// Adds a tooltip with the sort expression
TableCell cell =3D e.Item.Cells[i];
if (Columns[i].SortExpression !=3D "")
cell.ToolTip =3D "Sort by: " +
Columns[i].SortExpression;
// Draw the glyph to reflect sorting
if
(IsSortedByThisField(Columns[i].SortExpression))
{
cell.ToolTip =3D "Sorted by: " +
ViewState["CurrentSortExpression"].ToString();
Label lblSorted =3D new Label();
lblSorted.Font.Name =3D "webdings";
lblSorted.Font.Size =3D FontUnit.XSmall;
lblSorted.Text =3D GetOrderSymbol();
cell.Controls.Add(lblSorted);
}
}=09
}
}
---
Please note the above includes references for custom properties,
like PagerLinksCssClass, that are not shown. I believe all of these
properties are strings. I can give you the source for the modified
Grid.cs,
and my class that rides on top of it,
CreativeTechnology.Web.UI.WebControls.DataGrid if you'd (or anyone else
would) like.
HTH,
- Chuck
-----Original Message-----
From: Frode [mailto:fstroemm@o...]
Sent: Wednesday, May 15, 2002 11:34 AM
To: ASPX_Professional
Subject: [aspx_professional] Headerstyle and Pagerstyle
hi!
I would like to remove the underline of a headerstyle hyperlink, is this
possible.
I tried this but it didn't work:
<asp:BoundColumn
HeaderText=3D"Title"
DataField=3D"Title"
SortExpression=3D"Title"
HeaderStyle-Font-Underline=3D"False"
/>
Also, is there a way to customize the Pagerstyle more.
I feels a litte restricted that I have to choose between
Mode=3D"NumericPages" and Mode=3D"NextPrev"
I would like something like: first | prev | 1 2 3 | next | last
atm I feel I have better control over things like this in asp than in
asp.net, but that's just me I guess.
thanks
- Frode