ASPX templates
Version 5.x > ASPX templates > QueryDataList View modes: 
User avatar
Member
Member
eric.rovtar - 1/27/2011 10:36:40 PM
   
QueryDataList
Hi!

I'm using the CMSControls version of the QueryDataList, and I see there is a "Web Parts" version as well. It would seem that the Web Parts version has a paging control. Is that correct?

I want to to limit the page size to 10 and have the paging control automatically generated.

Thanks!

-Eric

User avatar
Member
Member
kentico_michal - 1/28/2011 5:57:59 AM
   
RE:QueryDataList
Hi Eric,

QueryDataList control uses DataPager for paging as it is described in following article: DataPager - overview.

Have you tried to set EnablePaging property of QueryDataList control to true? It should ensure paging and moreover there are many other DataPager properties which could be used to change DataPager behavior according to your needs.

Best regards,
Michal Legen

User avatar
Member
Member
eric.rovtar - 1/28/2011 10:37:43 AM
   
RE:QueryDataList
Michal:

I did and got this error:

EventDescription: Message: Unable to cast object of type 'CMS.Controls.DataPager' to type 'System.Web.UI.WebControls.DataListItem'.
Stack Trace:
at System.Web.UI.WebControls.DataList.GetItem(ListItemType itemType, Int32 repeatIndex)
at System.Web.UI.WebControls.DataList.System.Web.UI.WebControls.IRepeatInfoUser.GetItemStyle(ListItemType itemType, Int32 repeatIndex)
at System.Web.UI.WebControls.RepeatInfo.RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
at System.Web.UI.WebControls.DataList.RenderContents(HtmlTextWriter writer)
at CMS.Controls.QueryDataList.Render(HtmlTextWriter output)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer)
at System.Web.UI.PageRequestManager.RenderFormCallback(HtmlTextWriter writer, Control containerControl)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.HtmlFormWrapper.System.Web.UI.IHtmlForm.RenderControl(HtmlTextWriter writer)
at System.Web.UI.PageRequestManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

User avatar
Member
Member
kentico_michal - 2/1/2011 6:06:39 AM
   
RE:QueryDataList
Hi Eric,

Could you please let me know which version of Kentico CMS are you using?

Would it be possible to post here the code you are using?

Please also take a look at following simple code snippet which shows QueryDataList definition with paging enabled:

<cms:QueryDataList ID="lstItems" EnablePaging="true" PageSize="10" runat="server" />

Moreover, you can find example how to use cms:QueryDataList control with paging in QueryDataList web part (~CMSWebParts\Viewers\Query\querydatalist.ascx).


Best regards,
Michal Legen

User avatar
Member
Member
eric.rovtar - 2/1/2011 3:07:37 PM
   
RE:QueryDataList
Michael:

Here is my code:
qdlPodcastList.QueryName = "podcasts.podcast.selectAllSermonsPage";
qdlPodcastList.TransformationName = "podcasts.podcast.preview";
qdlPodcastList.WhereCondition = String.Format("{0}Date IS NOT NULL", Master.CurrentCampus.Replace(" ", ""));
qdlPodcastList.SelectedColumns = String.Format("{0}Date AS Date", Master.CurrentCampus.Replace(" ", ""));
qdlPodcastList.RepeatColumns = 1;
qdlPodcastList.CellSpacing = 10;
qdlPodcastList.PageSize = 10;
qdlPodcastList.OrderBy = "Date DESC";
qdlPodcastList.ZeroRowsText = "Sorry, but no podcasts were found.";
qdlPodcastList.ReloadData(true);


<cms:QueryDataList ID="qdlPodcastList" CssClass="qdlPodcastList"
runat="server">

<ItemStyle VerticalAlign="Top"></ItemStyle>

<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</cms:QueryDataList>


I took out the EnablePaging attribute to fix the error, but I'd still like to get paging enabled.

Thanks!

User avatar
Member
Member
kentico_michal - 2/3/2011 7:35:37 AM
   
RE:QueryDataList
Hi Eric,

The reason that causes this problem is following code in the QueryDataList definition:

<SeparatorTemplate>
<hr />
</SeparatorTemplate>


If you remove it and enable paging, it will work. In generall, it is currently not supported to define SeparatorTemplate and also enable paging in QueryDataList control. I am sorry for this inconvenience. I have set this as a future requirement and we will consider it for one of the future versions.


Best regards,
Michal Legen

User avatar
Member
Member
eric.rovtar - 2/3/2011 5:31:50 PM
   
RE:QueryDataList
No offense, that that's really lame. I hope it's fixed in the next release.

Is the same true for the QueryDataList web part?

I don't like that I'll have to sacrifice design to accommodate this.

Thanks!

User avatar
Member
Member
kentico_michal - 2/7/2011 10:07:33 AM
   
RE:QueryDataList
Hi Eric,

I can truly undestand your situation. On the other hand, this issue is much more complex and fixing it will require more time than standard bugs which are included into hotfix packages. For all these reasons, it was decided not to include this bug into hotfix package.

Anyway, we would recommend you to consider using combination of QueryDataList and external UniPager control instead of QueryDataList build-in DataPager control (which causes this issue). Please read following section to find more information about UniPager control

Best regards,
Michal Legen