protected void ButtonAddRobot_Click(object sender, EventArgs e)
        {
            WebUserControlRobots r = (WebUserControlRobots)LoadControl("~/WebUserControlRobots.ascx");

            r.ID = PlaceHolderRobots.Controls.Count.ToString() + "_Robot";

            PlaceHolderRobots.Controls.Add(r);

            List <WebUserControlRobotsData> rData = RobotsData; // Get it out of the viewstate

            WebUserControlRobotsData robotData = new WebUserControlRobotsData();

            robotData = r.Data;

            rData.Add(robotData);

            RobotsData = rData;
        }
        public void Robot_UserControlButtonRemoveClicked(object sender, EventArgs e)
        {
            // TO DO cast..
            WebUserControlRobots toDel = (WebUserControlRobots)sender;

            if (toDel != null)
            {
                // Find the index of the control
                int indexToDel = PlaceHolderRobots.Controls.IndexOf(toDel);
                if (indexToDel >= 0)
                {
                    List <WebUserControlRobotsData> rData = RobotsData; // Get it out of the viewstate
                    rData.RemoveAt(indexToDel);
                    RobotsData = rData;

                    LoadRobotsControls();
                    LoadRobotsEvents();
                }
            }
        }
        // Push the maps in the panelHolder again
        void LoadRobotsControls()
        {
            List <WebUserControlRobotsData> rData = RobotsData; // Get it out of the viewstate

            if (rData != null)
            {
                PlaceHolderRobots.Controls.Clear();

                int countID = 0;
                foreach (WebUserControlRobotsData r in rData)
                {
                    WebUserControlRobots robot = (WebUserControlRobots)LoadControl("~/WebUserControlRobots.ascx");
                    robot.LoadData(r);
                    robot.ID = countID.ToString() + "_Robot";
                    ++countID;

                    PlaceHolderRobots.Controls.Add(robot);
                }
            }

            RobotsData = rData;
        }
        public void Robot_UserControlFieldChanged(object sender, EventArgs e)
        {
            WebUserControlRobots r = (WebUserControlRobots)sender;

            if (r != null)
            {
                // Find the control.
                int indexOfControl = PlaceHolderRobots.Controls.IndexOf(r);
                if (indexOfControl >= 0)
                {
                    List <WebUserControlRobotsData> rData = RobotsData; // Get it out of the viewstate

                    if (rData.Count <= indexOfControl)
                    {
                        throw new ExecutionEngineException("Ooopps");
                    }

                    rData[indexOfControl] = ((RobotDataEventArgs)e).Data;
                    RobotsData            = rData;
                }
            }
        }