Gridview PagerStyle problem

K

kuangzhang

Dear MS Gurus,
I have read many posts on the Gridview pagerstyle problem but have yet
to see a fix or an work around.
Following is what I am experiencing:
in the Aspx Page I have this <PagerStyle CssClass="PagerSytle"/>

After render the Aspx page the HTML looks like this
<tr class="PagerStyle" >
<td colspan="9">
<table border="0">
<tr>
<td><span>1</span></td>
<td><a
href="javascript:__doPostBack('MyTasks$gvMy','Page$2')">2</a></td>
<td><a
href="javascript:__doPostBack('MyTasks$gvMy','Page$3')">3</a></td>
<td><a
href="javascript:__doPostBack('MyTasks$gvMy','Page$4')">4</a></td>
</tr>
</table>
</td>
From the above it easy to see why the style is not taking an effect.
With that said why is the gridview creating a subtable within the pager
tr/td? I can I get to that table to apply an style on it. Any help
would be greatly appreciated.
PS. I am not very sharp to please be specific ïŠ Thanks.
 
B

bruce barker \(sqlwork.com\)

use css inhertance:

<style>
tr.PagerStyle table {color:red}
tr.PagerStyle table tr {}
tr.PagerStyle table tr td {}
tr.PagerStyle table tr td span {color:blue}
tr.PagerStyle a {color:green}
</style>

-- bruce (sqlwork.com)

Dear MS Gurus,
I have read many posts on the Gridview pagerstyle problem but have yet
to see a fix or an work around.
Following is what I am experiencing:
in the Aspx Page I have this <PagerStyle CssClass="PagerSytle"/>

After render the Aspx page the HTML looks like this
<tr class="PagerStyle" >
<td colspan="9">
<table border="0">
<tr>
<td><span>1</span></td>
<td><a
href="javascript:__doPostBack('MyTasks$gvMy','Page$2')">2</a></td>
<td><a
href="javascript:__doPostBack('MyTasks$gvMy','Page$3')">3</a></td>
<td><a
href="javascript:__doPostBack('MyTasks$gvMy','Page$4')">4</a></td>
</tr>
</table>
</td>
From the above it easy to see why the style is not taking an effect.
With that said why is the gridview creating a subtable within the pager
tr/td? I can I get to that table to apply an style on it. Any help
would be greatly appreciated.
PS. I am not very sharp to please be specific ? Thanks.
 
Joined
Mar 9, 2011
Messages
1
Reaction score
0
Solution to font-size in GridView Pager with .NET

Since I couldn't find any solution, I had to find my own workaround.
Add these lines in OnPreRender on the page where the GridView, here named "gvReport", is:

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (null != gvReport.TopPagerRow)
{
((Table)gvReport.TopPagerRow.Cells[0].Controls[0]).Style.Add(HtmlTextWriterStyle.FontSize, "10pt");
}
if (null != gvReport.BottomPagerRow)
{
((Table)gvReport.BottomPagerRow.Cells[0].Controls[0]).Style.Add(HtmlTextWriterStyle.FontSize, "10pt");
}
}


Happy coding!
Lars
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top