Last post Oct 13, 2008 09:33 AM by bdemarzo
Feb 21, 2007 02:06 AM|S Boyer|LINK
In using the CSS Control Adapters on a paged GridView, initially all worked correctly. However, as soon as I added a PagerTemplate to the GridView markup, paging disappeared, never to return. I tracked this down to the WritePagerSection() method in GridViewAdapter,
which apparently only has logic to process the <table> tags that the ASP.NET GridView normally uses for the built-in paging markup. I confirmed this by building a PagerTemplate like this:
<PagerTemplate><asp:Table ID="tmp" runat="server"><asp:TableRow runat="server"><asp:TableCell runat="server">
<asp:LinkButton Tooltip="Previous Page" CommandName="Page" CommandArgument="Prev" runat="server" ID="btnPrevious" OnCommand="Paginate" >Previous</asp:LinkButton>
which correctly outputs the paging section (no spaces or returns may be between PagerTemplate and the table tags or the WritePagerSection() logic sees the them as a Literal and ignores the PagerTemplate, or more precisely the contents of the Top/BottomPagerRow).
I'm not very familiar with the Template/ControlBuilder area of ASP.NET, but I think that by the time WritePagerSection() is called, Top/BottomPagerRow contains the parsed control array from PagerTemplate. I implemented else logic in WritePagerSection()
to simply iterate over the Controls collection from Top/BottomPagerRow and call RenderControl (wrapping it all with a <div> as the existing logic does).
Is this a known issue? Is my simple solution of iterating over the controls array with RenderControl sufficient in all cases?
Mar 06, 2007 09:07 AM|t0ny|LINK
I think I am slightly lost here, but certainly the CSS Control Adapters don't render my PagerTemplate within my GridView.
<!--<adapter controlType="System.Web.UI.WebControls.GridView" adapterType="CSSFriendly.GridViewAdapter" />-->
Does anyone have a solution?
Apr 16, 2007 12:57 PM|Nobles350|LINK
Apr 16, 2007 04:31 PM|whatispunk|LINK
This same problem exists with the FormView control as well.
A fix would be greatly appreciated!
May 18, 2007 04:13 PM|alvinling|LINK
The code below works but there's still a problem with skinned controls rendering properly (regular server controls render fine)
private void WritePagerSection(HtmlTextWriter writer, PagerPosition pos)
GridView gridView = Control as GridView;
if (gridView != null &&
gridView.PageCount > 1 &&
(gridView.PagerSettings.Position == pos || gridView.PagerSettings.Position == PagerPosition.TopAndBottom))
string className = "AspNet-GridView-Pagination AspNet-GridView-";
className += (pos == PagerPosition.Top) ? "Top " : "Bottom ";
if (gridView.PagerStyle != null)
className += gridView.PagerStyle.CssClass;
className = className.Trim();
if (gridView.PagerTemplate != null)
PlaceHolder container = new PlaceHolder();
Table innerTable = null;
if ((pos == PagerPosition.Top) &&
(gridView.TopPagerRow != null) &&
(gridView.TopPagerRow.Cells.Count == 1) &&
(gridView.TopPagerRow.Cells.Controls.Count == 1) &&
innerTable = gridView.TopPagerRow.Cells.Controls as Table;
else if ((pos == PagerPosition.Bottom) &&
(gridView.BottomPagerRow != null) &&
(gridView.BottomPagerRow.Cells.Count == 1) &&
(gridView.BottomPagerRow.Cells.Controls.Count == 1) &&
innerTable = gridView.BottomPagerRow.Cells.Controls as Table;
if ((innerTable != null) && (innerTable.Rows.Count == 1))
TableRow row = innerTable.Rows;
foreach (TableCell cell in row.Cells)
foreach (Control ctrl in cell.Controls)
May 23, 2007 01:26 AM|atomiton|LINK
will this code also apply to the FormView template as well?
May 25, 2007 03:39 PM|atomiton|LINK
In Case anyone is wondering, I was at CodePlex for the DLL for the adapters and it looks like someone is addressing that the FormView didn't have all the paging options implemented but it's being worked on now. (that was a poorly constructed sentence)
May 25, 2007 05:50 PM|bdemarzo|LINK
Changed 1588 has the full set of paging features for FormView and DetailsView.
Note that a few pending changes to GridView are there, but there is not yet a test page in the WalkThru. If someone wants to draft up a test page (similar to the other WalkThru test pages) please feel free to and submit it as a patch.
Jul 26, 2007 11:54 AM|ryanrr|LINK
None of the CSS Adapters seem to handle the Templates properly. Even the above suggested fix is limited to design-time markup. It appears that simply calling the .InstantiateIn method of the Template is not enough for it to render server controls modified
at run-time properly. The EmptyDataTemplate for the GridView does seem to work because it uses a different technique which I don't see being able to apply to a PagerTemplate. The DetailsView and FormView EmptyDataTemplates also have this problem (as well as
Example (using DetailsView in WalkThru):
void DetailsViewSample_ItemCreated(object sender,
ph = DetailsViewSample.FindControl("phTest")
if (ph !=
Trace.Warn("Found empty data row.");
This won't display anything with the CSS adapter enabled even though the trace hits normally. CSS Adapter disabled, the row will display the correct "testing" value. This can be a real problem when you want to implement a nice, dynamic PagerTemplate.
I don't quite grok how templates work to suggest a solution, however.
Oct 09, 2008 05:18 AM|TheAlps|LINK
Was this problem ever fixed? I am using CSSFriendly for the nice menu features and now im deep in the code and my custom paging template in GridView totally doesnt work with CSSFriendly. Seems odd that a year ago there were problems and they havent been
addressed. Has this project been dropped?
Oct 13, 2008 09:33 AM|bdemarzo|LINK
You may want to test the latest version of the code from CodePlex (http://www.codeplex.com/cssfriendly). I know there have been pager-related check-ins, and they may have addressed your issues.