Home All Groups Group Topic Archive Search About

Adding controls to Pager row in GridView

Author
27 Mar 2006 2:35 PM
J055
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

Author
27 Mar 2006 2:55 PM
Phillip Williams
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);
  }
}

Show quoteHide quote
"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
>
>
>
Author
27 Mar 2006 3:20 PM
J055
Thanks for that.

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

Cheers
Andrew


Show quoteHide quote
"Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
news:0DBE3E67-5746-4BC4-A761-D7290F4DF5D0@microsoft.com...
> 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
>>
>>
>>
Author
27 Mar 2006 3:34 PM
Phillip Williams
Try them. 

As for the columnspan put 0 (you will see that you have to compensate for
that layout by adding other columns)
Show quoteHide quote
"J055" wrote:

> Thanks for that.
>
> Is it possible to remove attributes like colspan, width etc?
>
> Cheers
> Andrew
>
>
> "Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
> news:0DBE3E67-5746-4BC4-A761-D7290F4DF5D0@microsoft.com...
> > 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
> >>
> >>
> >>
>
>
>
Author
27 Mar 2006 3:52 PM
J055
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


Show quoteHide quote
"Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
news:CE25B30E-AF35-494B-9601-7E6CCB703280@microsoft.com...
> 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" <WEBSWAPP@newsgroups.nospam> wrote in message
>> news:0DBE3E67-5746-4BC4-A761-D7290F4DF5D0@microsoft.com...
>> > 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
>> >>
>> >>
>> >>
>>
>>
>>
Author
28 Mar 2006 3:25 AM
Steven Cheng[MSFT]
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.