Adding controls to Pager row in GridView

J

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
 
P

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);
}
}
 
J

J055

Thanks for that.

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

Cheers
Andrew


Phillip Williams said:
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 said:
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
 
P

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)
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


J055 said:
Thanks for that.

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

Cheers
Andrew


Phillip Williams said:
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 said:
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
 
J

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


Phillip Williams said:
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 said:
Thanks for that.

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

Cheers
Andrew


Phillip Williams said:
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


:

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
 
S

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top