Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Adding controls to Pager row in GridView (http://www.velocityreviews.com/forums/t777805-adding-controls-to-pager-row-in-gridview.html)

J055 03-27-2006 02:35 PM

Adding controls to Pager row in GridView
 
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 03-27-2006 02:55 PM

RE: Adding controls to Pager row in GridView
 
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 03-27-2006 03:20 PM

Re: Adding controls to Pager row in GridView
 
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
>>
>>
>>




Phillip Williams 03-27-2006 03:34 PM

Re: Adding controls to Pager row in GridView
 
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
> >>
> >>
> >>

>
>
>


J055 03-27-2006 03:52 PM

Re: Adding controls to Pager row in GridView
 
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" <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
>> >>
>> >>
>> >>

>>
>>
>>




Steven Cheng[MSFT] 03-28-2006 03:25 AM

Re: Adding controls to Pager row in GridView
 
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.



All times are GMT. The time now is 03:08 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.