RadDocks and State loaded from DB

2 posts, 0 answers
  1. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 08 May 2009 Link to this post

    I am loading RadDocks from SQL and state as well, I'm having trouble with RadDock.ApplyState(state)..  There has to be a loop from the database to load the controls but at the same time there has to be a loop to apply the state, does anyone have an example of this?

    Here is the code I am talking about, this loop is based on the propery list of DockState

    Protected Sub Page_Init(ByVal sender As ObjectByVal e As EventArgs) 
                Dim i As Integer = 0 
                While i < CurrentDockStates.Count 
                    Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i)) 
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1) 
                End While 
            End Sub 

    However I load the usercontrols into RadDocks with a While Loop from a datareader like this:

       Protected Sub Page_Init(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Init 
            Dim RoleID As Integer 
            Dim drContacts As SqlDataReader 
            Dim control As New Web.UI.Control() 
            Dim count As Integer = 0 
            Dim state As New DockState() 
            Dim Edit As String = Utilities.GetSession("Edit Layout Allowed"
            RoleID = Int32.Parse(Utilities.GetSession("PortalRoleID")) 
            drContacts = PortalDataAccess.GetPortalControlsByRoleID(RoleID) 
            If (drContacts.HasRows) Then 
                While (drContacts.Read()) 
                    Dim soRadDock As New RadDock() 
                    soRadDock.ID = drContacts("ControlID").ToString() 
                    soRadDock.Title = drContacts("ControlTitle").ToString() 
                    control = LoadControl("UserControls/" & drContacts("ControlName").ToString() & ".ascx"
                    If drContacts("Zone") = 1 Then 
                    End If 
                    If drContacts("Zone") = 0 Then 
                    End If 
                End While 
            End If 
        End Sub 

    So my problem is in order to call ApplyState(State) in Page_Init and get the correct closed , collapsed state from the DB I need to have 2 loops........ Not sure how to accomplish this. The underlying issue is the Closed and Collapsed state is being overwritten before the controls render and Im losing those 2 pieces of state.


  2. Petio Petkov
    Petio Petkov avatar
    825 posts

    Posted 12 May 2009 Link to this post

    Hi Sam,

    I created for you a simple example which loads/save state in DB and RadDocks are created dynamically - please find it attached. The Dock.ApplyState method is invoked when the RadDock is created from the state.

    Sincerely yours,
    Petio Petkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top