Wednesday, August 3, 2011

Get all Calendar Workspace Events in Sharepoint 2010

       try
            {
                oWeb = SPContext.Current.Web;
                SPList oCalendarList = oWeb.Lists.TryGetList("Calendar");


                string strEvent = @"
                              <Where>
                                    <Eq>
                                        <FieldRef Name='WorkspaceLink' />
                                        <Value Type='CrossProjectLink'>1</Value>
                                    </Eq>
                                </Where>
                                <OrderBy>
                                    <FieldRef Name='Modified' Ascending='False' />
                                </OrderBy>
                             ";
                SPQuery query = new SPQuery();
                query.Query = strEvent;
                SPListItemCollection oListItemCol = oCalendarList.GetItems(query);

                dtWorkspace = oListItemCol.GetDataTable();
                gvWorkspaceLinks.DataSource = dtWorkspace;
                gvWorkspaceLinks.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oWeb.Dispose();
            }

No comments:

Post a Comment

Followers

Blog Archive