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

raddock

1 Answer 20 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Sigma
Top achievements
Rank 1
Sigma asked on 24 Aug 2012, 09:34 AM
hi,,
how to save and load state of raddock in database..

thanks..

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Aug 2012, 10:49 AM
Hi,

Try the following code snippet to save and load state of RadDock in database.

C#:
private List<DockState> CurrentDockStates
        {
            get
            {
                //Get saved state string from the database - set it to dockState variable for example
                string dockStatesFromDB = "";
                _conn.Open();
                SqlCommand command = new SqlCommand("select State from States where id='" + _userID + "' ", _conn);
                dockStatesFromDB = command.ExecuteScalar().ToString();
                _conn.Close();
                List<DockState> _currentDockStates = new List<DockState>();
                string[] stringStates = dockStatesFromDB.Split('|');
                foreach (string stringState in stringStates)
                {
                    if (stringState.Trim() != string.Empty)
                    {
                        _currentDockStates.Add(DockState.Deserialize(stringState));
                    }
                }
                return _currentDockStates;
            }
        }
  
  
protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
        {
            List<DockState> stateList = RadDockLayout1.GetRegisteredDocksState();
            StringBuilder serializedList = new StringBuilder();
            int i = 0;
            while (i < stateList.Count)
            {
                serializedList.Append(stateList[i].ToString());
                serializedList.Append("|");
                i++;
            }
            string dockState = serializedList.ToString();
            if (dockState.Trim() != String.Empty)
            {
                _conn.Open();
                SqlCommand command = new SqlCommand(String.Format("update States set State='{0}' where id='" + _userID + "'", dockState), _conn);
                command.ExecuteNonQuery();
                _conn.Close();
            }
        }
protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
        {
            //Populate the event args with the state information. The RadDockLayout control
            // will automatically move the docks according that information.
            foreach (DockState state in CurrentDockStates)
            {
                e.Positions[state.UniqueName] = state.DockZoneID;
                e.Indices[state.UniqueName] = state.Index;
            }
        }
Also take a look into the following code libraries.
Saving State of Dynamically Created RadDocks in DataBase using Hidden UpdatePanel
Save DockState in DataBase using RadAjaxManager

Thanks,
Shinu.
Tags
Dock
Asked by
Sigma
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or