PageList not showing programatically addded Pages

Vote:
 

Helloh, I'm experiencing a somewhat odd problem. Have a page list and a button, the button adds a page programatically. And the pagelist is databound. But the Page list doesn't show the newly added page.

 

 

Codebehind (stripped down): 

protected override void OnLoad(System.EventArgs e)
{
base.OnLoad(e);
if (!IsPostBack)
{
pl.PageLink = CurrentPage.PageLink;
DataBind();
}
}


protected void click(object sender, EventArgs e)
{
PageData a = EPiServer.DataFactory.Instance.GetDefaultPageData(CurrentPage.PageLink, 3, EPiServer.Security.AccessLevel.NoAccess);
a.PageName = DateTime.Now.ToLongTimeString();
EPiServer.DataFactory.Instance.Save(a, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
pl.DataBind();
}

//markup had to remove gt/lt because editor in forum acts weird.
  (asp:Content ContentPlaceHolderID="MainRegion" runat="server")
(EPiServer:PageList runat="server" ID="pl" )

(ItemTemplate)
(%# Container.CurrentPage.PageName %)

(/ItemTemplate)

(/EPiServer:PageList)

(asp:Button Text="add" OnClick="click" runat="server" /)

(/asp:Content)

    

 

 

 

 

 

 

 

#30357
Jun 12, 2009 14:03
Vote:
 
Try to set a.StartPublish = DateTime.Now.AddSeconds(-1);
#30363
Jun 12, 2009 14:59
Vote:
 

Hi!

I possible reason for this could be the start publish date. Since you don't set a start publish date DateTime.Now will be used as StartPublish date.

What that means is that the page will have a start publish that is basically the same as the time the request is made. And with a bit of (un)luck the page will be seen as not published and hence not visible for user with only read access to the page. We've made some improvents to handle this scenario better that will be included in SP2. It's a bit tricky though, since the date is saved and read from the database, and the database granuality isn't as good as ASP.NET:s, hence you can loose or gain one or two milliseconds on the date.

So, try adding a start publish time slightly in the past and see if it makes a difference.

a.StartPublish = DateTime.Now.AddMinutes(-1)

Regards

Per Gunsarfs
EPiServer CMS development team

#30364
Edited, Jun 12, 2009 15:02
Vote:
 

Hi,

it worked - thanks alot :)

#30760
Jun 18, 2009 14:36
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.