0

I have created a SPCalendarView control in a visualwebpart[i have tried the same in the Webpart as well] for binding the events from a calendar list based on the start and end dates. I get the events from the calendar list for the current month and bind it to the spcalendarview for the current month.It works fine in this case. For the next month's or the previous month's events i bind events from the list when i click the next button in the spcalendar view based on the value i get from the query string paramater calendarDate. [This is done as the list has too many events].

The above works in sharepoint foumdation 2010. But when i use the same code in sharepoint server 2010 i am not able to see the events for the next and previous months. The events are seen only for the current months.Binding happens in the serverside code but i am not able to see the events in the UI.

Please help me with the same. Thanks in advance :)

0

Try the following code:

i have used gridview for bind username and password. the textbox is used to start and end date of the calender. when click the button then the username is the text of the event in calender.

         protected void Button1_Click1(object sender, EventArgs e)
           {
           var qry = (from logi in entities.Login
                   where logi.UserName == TextBox3.Text
                   orderby Convert.ToDateTime(logi.Password)
                   ascending
                   select new
                   {
                       UserName = logi.UserName,
                       Password = logi.Password
                   }).ToList();
        GridView1.DataSource = qry;
        GridView1.DataBind();

        foreach (GridViewRow row in GridView1.Rows)
        {
            if (active == 0)
            {
                int i = row.RowIndex;
                Label lbl1 = (Label)GridView1.Rows[0].Cells[0].FindControl("Label2");
                DateTime dt = Convert.ToDateTime(lbl1.Text);

                Label lbl11 = (Label)GridView1.Rows[1].Cells[0].FindControl("Label2");
                DateTime dt1 = Convert.ToDateTime(lbl11.Text);
                using (SPSite site = new SPSite("Sharepointsite"))
                {
                    using (SPWeb web = site.RootWeb)
                    {
                        SPList list = web.Lists["Calendar1"];
                        web.AllowUnsafeUpdates = true;
                        SPListItem Event = list.Items.Add();
                        Event["Title"] = TextBox3.Text;
                        Event["EventDate"] = Convert.ToDateTime(dt);
                        Event["EndDate"] = Convert.ToDateTime(dt1);
                        Event.Update();
                        list.Update();
                    }

                }
            }

            active = 1;
        }
        active = 0;
    }
0

CU Dec2011 ( http://support.microsoft.com/kb/2596998 ) solved the problem about SPCalendarView in SP2010

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.