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:
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?
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)
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.
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
their PagerTemplates).
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.
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?
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.
None
0 Points
1 Post
GridView Adapter with PagerTemplate broken
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>
</asp:TableCell></asp:TableRow></asp:Table></PagerTemplate>
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?
Thanks, Shane
Member
1 Points
28 Posts
Re: GridView Adapter with PagerTemplate broken
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.
I have had to comment out the gridview adaptor, which is a big shame[:(]:<!--<adapter controlType="System.Web.UI.WebControls.GridView" adapterType="CSSFriendly.GridViewAdapter" />-->
Does anyone have a solution?
None
0 Points
2 Posts
Re: GridView Adapter with PagerTemplate broken
Apr 16, 2007 12:57 PM|Nobles350|LINK
Contributor
2499 Points
863 Posts
Re: GridView Adapter with PagerTemplate broken
Apr 16, 2007 04:31 PM|whatispunk|LINK
This same problem exists with the FormView control as well.
A fix would be greatly appreciated!
Why UpdatePanels Are Dangerous
Why You Should Not Place Your Whole Site In An UpdatePanel
None
0 Points
2 Posts
Re: GridView Adapter with PagerTemplate broken
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)
Member
40 Points
39 Posts
Re: GridView Adapter with PagerTemplate broken
May 23, 2007 01:26 AM|atomiton|LINK
will this code also apply to the FormView template as well?
Member
40 Points
39 Posts
Re: GridView Adapter with PagerTemplate broken
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)
Stay Tuned.
http://www.codeplex.com/cssfriendly/SourceControl/ListDownloadableCommits.aspx
css adapters
Member
60 Points
166 Posts
Re: GridView Adapter with PagerTemplate broken
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.
- blog: www.sidesofmarch.com
None
0 Points
6 Posts
Re: GridView Adapter with PagerTemplate broken
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 their PagerTemplates).
Example (using DetailsView in WalkThru):
<div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><EmptyDataTemplate>
<asp:PlaceHolder ID="phTest" runat="server" />
</EmptyDataTemplate>
protected void DetailsViewSample_ItemCreated(object sender, EventArgs e)
{
ph = DetailsViewSample.FindControl("phTest") as PlaceHolder;
if (ph != null)
{
Trace.Warn("Found empty data row.");
ph.Controls.Add(new LiteralControl("testing"));
}
}
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.
</div>None
0 Points
13 Posts
Re: GridView Adapter with PagerTemplate broken
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?
Member
60 Points
166 Posts
Re: GridView Adapter with PagerTemplate broken
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.
- blog: www.sidesofmarch.com