Hi.
I have succesfully implemented the data provider (following http://www.telerik.com/help/aspnet-ajax/schedule_databindingimplementingaproviderthatsupportsmultivaluedresources.html).
The provider gets the logged on user's appointments and displays them accordingly. However, a user needs to be able to view other user's calendars (though not edit them). Therefore I need to send a parameter to the provider in order to display the correct user's appointments.
The trouble so far has been that I do not seem to bind the data correctly.
I use a DropDownList to change the active user, and when I first choose a user (say John) nothing changes. When I choose another user (say Laura), John's data is displayed. Choosing a third user, displays Laura's data and so forth. Therefore there must be something wrong with the timing.
Moreover, if I change the timeview, e.g. from Day to Month, the data of the original user is displayed.
I only set the original UserID in the Page_Load event and inside an if (!IsPostBack) check.
When the selected index is changed in the DropDownList, the ddlChange is fired, and UserID is updated for the RadScheduler. See code below.
When the selected index is changed in the DropDownList, the ddlChange is fired, and UserID is updated for the RadScheduler. See code below.
| private void Page_Load(object sender, EventArgs e) |
| { |
| if (User.Identity.IsAuthenticated) |
| { |
| MembershipUser mu = Membership.GetUser(); |
| UserID = (Guid)mu.ProviderUserKey; |
| } |
| if(!IsPostBack) |
| { |
| UserProvider p = (UserProvider )RadScheduler1.Provider; |
| p.UserID = UserID; |
| } |
| } |
| protected void ddlChanged(object sender, EventArgs e) |
| { |
| DropDownList ddl = (DropDownList)PanelBar.Items[0].Items[0].FindControl("ddlUsers"); |
| string tmpUserID = ddl.SelectedValue.ToString(); |
| if (tmpUserID == "0") //Meaning that the default/original user is selected |
| { |
| //UserID is the original user's id |
| RadScheduler1.Attributes["UserID"] = UserID.ToString(); |
| UserProvider p = (UserProvider )RadScheduler1.Provider; |
| p.UserID = UserID; |
| RadScheduler1.ReadOnly = false; |
| } |
| else |
| { |
| RadScheduler1.Attributes["UserID"] = tmpUserID.ToString(); |
| UserProvider p = (UserProvider )RadScheduler1.Provider; |
| p.UserID = new Guid(tmpUserID.ToString()); |
| RadScheduler1.ReadOnly = true; |
| } |
| RadScheduler1.DataBind(); |
| } |
Hope you might help me with this :)
Thanks in advance.