Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Any body know how to filter calendar? I tried these code

protected override void CreateChildControls()
{
    base.CreateChildControls();

    using (SPWeb web = SPContext.Current.Site.OpenWeb("/test"))
    {
        SPList list = web.GetListByUrl("/Lists/TestCalendar");
        SPView view = list.Views["Calendar"];

        ListViewWebPart webPart = new ListViewWebPart();

        webPart.WebId = web.ID;
        webPart.ListId = list.ID;
        webPart.PageType = PAGETYPE.PAGE_DEFAULTVIEW;
        webPart.ViewContentTypeId = "0x";
        webPart.ListViewXml = GetViewXml(view);

        Controls.Add(webPart);
    }
}

private string GetViewXml(SPView view)
{
    if (ApplySearch)
    {
        view.Query = "my custom query";
    }

    return view.GetViewXml();
}

It works fine for any view except Calendar. I cannot understand What the difference and how can i solve this issue.

share|improve this question
    
What is "my custom query", there can be a problem in CAML Query, please post it as well –  Arsalan Adam Khatri Dec 17 '12 at 15:31
    
@ArsalanAdamKhatri, This query is not complex and it works correctly. I'm sure because I tested this query on all items view of my calendar list. –  Alexander Dec 17 '12 at 16:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.