This is a migrated thread and some comments may be shown as answers.

[Solved] Passing custom attribute to data provider

1 Answer 162 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
R
Top achievements
Rank 1
R asked on 09 Jan 2010, 08:26 PM
Hi.

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.
    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.

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Jan 2010, 02:27 PM
Hello R,

Please, view the kb article on How to pass parameters to a custom database provider and let us know if you have further questions.


All the best,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Scheduler
Asked by
R
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or