Adding controls to Pager row in GridView

Discussion in 'ASP .Net Web Controls' started by J055, Mar 27, 2006.

  1. J055

    J055 Guest

    Hi

    I'd like to display some information about the GridView records in the Pager
    rows.

    e.g. Records 1 to 10 of 100

    I can add a new TableCell control to the DataControlRowType.Pager rows but I
    can see a problem. The Pager row adds a colspan equal to it's td tag which
    is equal to the number of DataRow columns.

    Can I modify this? I don't know how. Or do I need to use a PagerTemplate to
    to this? If so can anyone point me to some good references on how to do
    this?

    Many thanks
    Andrew
    J055, Mar 27, 2006
    #1
    1. Advertising

  2. void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType==DataControlRowType.Pager)
    {
    HyperLink hlink= new HyperLink();
    hlink.NavigateUrl="AnotherPage.aspx";
    hlink.Text="PageTitle";
    //decrease the colspan of the cell by one to add another cell
    e.Row.Cells[0].ColumnSpan --;
    TableCell td = new TableCell();
    td.Controls.Add(hlink);
    e.Row.Cells.Add(td);
    }
    }

    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "J055" wrote:

    > Hi
    >
    > I'd like to display some information about the GridView records in the Pager
    > rows.
    >
    > e.g. Records 1 to 10 of 100
    >
    > I can add a new TableCell control to the DataControlRowType.Pager rows but I
    > can see a problem. The Pager row adds a colspan equal to it's td tag which
    > is equal to the number of DataRow columns.
    >
    > Can I modify this? I don't know how. Or do I need to use a PagerTemplate to
    > to this? If so can anyone point me to some good references on how to do
    > this?
    >
    > Many thanks
    > Andrew
    >
    >
    >
    Phillip Williams, Mar 27, 2006
    #2
    1. Advertising

  3. J055

    J055 Guest

    Thanks for that.

    Is it possible to remove attributes like colspan, width etc?

    Cheers
    Andrew


    "Phillip Williams" <> wrote in message
    news:...
    > void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    > {
    > if (e.Row.RowType==DataControlRowType.Pager)
    > {
    > HyperLink hlink= new HyperLink();
    > hlink.NavigateUrl="AnotherPage.aspx";
    > hlink.Text="PageTitle";
    > //decrease the colspan of the cell by one to add another cell
    > e.Row.Cells[0].ColumnSpan --;
    > TableCell td = new TableCell();
    > td.Controls.Add(hlink);
    > e.Row.Cells.Add(td);
    > }
    > }
    >
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "J055" wrote:
    >
    >> Hi
    >>
    >> I'd like to display some information about the GridView records in the
    >> Pager
    >> rows.
    >>
    >> e.g. Records 1 to 10 of 100
    >>
    >> I can add a new TableCell control to the DataControlRowType.Pager rows
    >> but I
    >> can see a problem. The Pager row adds a colspan equal to it's td tag
    >> which
    >> is equal to the number of DataRow columns.
    >>
    >> Can I modify this? I don't know how. Or do I need to use a PagerTemplate
    >> to
    >> to this? If so can anyone point me to some good references on how to do
    >> this?
    >>
    >> Many thanks
    >> Andrew
    >>
    >>
    >>
    J055, Mar 27, 2006
    #3
  4. Try them.

    As for the columnspan put 0 (you will see that you have to compensate for
    that layout by adding other columns)
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "J055" wrote:

    > Thanks for that.
    >
    > Is it possible to remove attributes like colspan, width etc?
    >
    > Cheers
    > Andrew
    >
    >
    > "Phillip Williams" <> wrote in message
    > news:...
    > > void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    > > {
    > > if (e.Row.RowType==DataControlRowType.Pager)
    > > {
    > > HyperLink hlink= new HyperLink();
    > > hlink.NavigateUrl="AnotherPage.aspx";
    > > hlink.Text="PageTitle";
    > > //decrease the colspan of the cell by one to add another cell
    > > e.Row.Cells[0].ColumnSpan --;
    > > TableCell td = new TableCell();
    > > td.Controls.Add(hlink);
    > > e.Row.Cells.Add(td);
    > > }
    > > }
    > >
    > > --
    > > HTH,
    > > Phillip Williams
    > > http://www.societopia.net
    > > http://www.webswapp.com
    > >
    > >
    > > "J055" wrote:
    > >
    > >> Hi
    > >>
    > >> I'd like to display some information about the GridView records in the
    > >> Pager
    > >> rows.
    > >>
    > >> e.g. Records 1 to 10 of 100
    > >>
    > >> I can add a new TableCell control to the DataControlRowType.Pager rows
    > >> but I
    > >> can see a problem. The Pager row adds a colspan equal to it's td tag
    > >> which
    > >> is equal to the number of DataRow columns.
    > >>
    > >> Can I modify this? I don't know how. Or do I need to use a PagerTemplate
    > >> to
    > >> to this? If so can anyone point me to some good references on how to do
    > >> this?
    > >>
    > >> Many thanks
    > >> Andrew
    > >>
    > >>
    > >>

    >
    >
    >
    Phillip Williams, Mar 27, 2006
    #4
  5. J055

    J055 Guest

    I've been trying to get rid of 'border' from the table element, i.e.

    <table border="0">...</table>

    but it appears that the table class dosn't have a border property. Very
    strange - it has everything else, CellPadding, CellSpacing etc but no Border
    but it renders 'border="0"' into the table. I guess it must be hardwired?

    Am I missing something here?

    Thanks
    Andrew


    "Phillip Williams" <> wrote in message
    news:...
    > Try them.
    >
    > As for the columnspan put 0 (you will see that you have to compensate for
    > that layout by adding other columns)
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "J055" wrote:
    >
    >> Thanks for that.
    >>
    >> Is it possible to remove attributes like colspan, width etc?
    >>
    >> Cheers
    >> Andrew
    >>
    >>
    >> "Phillip Williams" <> wrote in message
    >> news:...
    >> > void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    >> > {
    >> > if (e.Row.RowType==DataControlRowType.Pager)
    >> > {
    >> > HyperLink hlink= new HyperLink();
    >> > hlink.NavigateUrl="AnotherPage.aspx";
    >> > hlink.Text="PageTitle";
    >> > //decrease the colspan of the cell by one to add another cell
    >> > e.Row.Cells[0].ColumnSpan --;
    >> > TableCell td = new TableCell();
    >> > td.Controls.Add(hlink);
    >> > e.Row.Cells.Add(td);
    >> > }
    >> > }
    >> >
    >> > --
    >> > HTH,
    >> > Phillip Williams
    >> > http://www.societopia.net
    >> > http://www.webswapp.com
    >> >
    >> >
    >> > "J055" wrote:
    >> >
    >> >> Hi
    >> >>
    >> >> I'd like to display some information about the GridView records in the
    >> >> Pager
    >> >> rows.
    >> >>
    >> >> e.g. Records 1 to 10 of 100
    >> >>
    >> >> I can add a new TableCell control to the DataControlRowType.Pager rows
    >> >> but I
    >> >> can see a problem. The Pager row adds a colspan equal to it's td tag
    >> >> which
    >> >> is equal to the number of DataRow columns.
    >> >>
    >> >> Can I modify this? I don't know how. Or do I need to use a
    >> >> PagerTemplate
    >> >> to
    >> >> to this? If so can anyone point me to some good references on how to
    >> >> do
    >> >> this?
    >> >>
    >> >> Many thanks
    >> >> Andrew
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
    J055, Mar 27, 2006
    #5
  6. Hi Andrew,

    As for the border, it is controlled by the Table control's BorderWidth
    property, individual cell or row's border setting won't affect the whole
    table's setting. For your scenario, I think you can consider copy the
    orginal pager controls from the pager cell into a new created Table
    control, we can apply whatever style on the new created Table. And in the
    end add the new Table into the original Pager Cell. for example:

    =============================
    protected void GridView1_RowCreated1(object sender, GridViewRowEventArgs e)
    {

    if (e.Row.RowType == DataControlRowType.Pager)
    {

    Table tb = new Table();
    tb.BorderWidth = 0;
    tb.Width = Unit.Percentage(100);
    tb.Rows.Add(new TableRow());
    tb.Rows[0].Cells.Add(new TableCell());

    tb.Rows[0].Cells.Add(new TableCell());


    HyperLink hlink = new HyperLink();
    hlink.NavigateUrl = "AnotherPage.aspx";
    hlink.Text = "PageTitle";

    tb.Rows[0].Cells[1].Controls.Add(hlink);
    tb.Rows[0].Cells[1].HorizontalAlign = HorizontalAlign.Right;

    foreach (Control ctrl in e.Row.Cells[0].Controls)
    {
    tb.Rows[0].Cells[0].Controls.Add(ctrl);
    }

    e.Row.Cells[0].Controls.Add(tb);
    }

    }
    ================================

    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Mar 28, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c3Ryb3V0?=

    Adding a dropdownlist in DataGrid Pager area

    =?Utf-8?B?c3Ryb3V0?=, Jan 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    397
    Philip Q [MVP]
    Jan 12, 2005
  2. H5N1
    Replies:
    0
    Views:
    2,697
  3. Replies:
    5
    Views:
    645
  4. Nathan Sokalski
    Replies:
    5
    Views:
    504
    Gaurav Vaish \(www.edujini-labs.com\)
    Jan 27, 2007
  5. rk325

    Datagrid: resize font in Pager row

    rk325, Dec 23, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    154
    John Saunders
    Dec 24, 2004
Loading...

Share This Page