private void SetSelectedItemFromQueryString()
        {
            string id = string.Empty;

            if (Page.Request["tabid"] != null)
            {
                id = Page.Request["tabid"].Replace("__", ":");
            }

            int ctr = 1;
            foreach (TabItem tabItem in _tabItems)
            {
                tabItem.Id_internal = this.ClientID + "Item" + ctr.ToString();

                if (tabItem.Id.Equals(id, StringComparison.CurrentCultureIgnoreCase))
                {
                    tabItem.Selected = true;
                    this._selectedTabItem = tabItem;
                }
                else
                {
                    tabItem.Selected = false;
                }

                ctr++;
            }
        }
        public void RaisePostBackEvent(string eventArgument)
        {
            this.SetSelectedItem(eventArgument);

            if (this._selectedTabItem != null)
            {
                TabItemClickedEventArgs eventArgs =
                    new TabItemClickedEventArgs(_selectedTabItem, _lastSelectedTabItem);

                OnTabItemClicked(eventArgs);

                if (eventArgs.Cancel)
                {
                    this._selectedTabItem.Selected = false;

                    if (this._lastSelectedTabItem != null)
                        this._lastSelectedTabItem.Selected = true;

                    this._selectedTabItem = this._lastSelectedTabItem;
                }
            }
        }
 public TabItemClickedEventArgs(TabItem selectedTabItem, TabItem lastSelectedTabItem)
 {
     this.selectedTabItem = selectedTabItem;
     this.lastSelectedTabItem = lastSelectedTabItem;
 }
        private void SetSelectedItem(string id)
        {
            int ctr = 1;
            foreach (TabItem tabItem in _tabItems)
            {
                tabItem.Id_internal = this.ClientID + "Item" + ctr.ToString();

                if (tabItem.Selected)
                {
                    this._lastSelectedTabItem = tabItem;
                    tabItem.Selected = false;
                }

                if (tabItem.Id.Equals(id, StringComparison.CurrentCultureIgnoreCase))
                {
                    tabItem.Selected = true;
                    this._selectedTabItem = tabItem;
                }
                else
                {
                    tabItem.Selected = false;
                }

                ctr++;
            }
        }
        public void Remove(TabItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            int index = IndexOf(item);
            if (index >= 0)
            {
                RemoveAt(index);
            }
        }
        private void CreateFieldsInTabs(Control container)
        {
            Fields = new System.Collections.Hashtable();

            // create a tabstrip with the categories
            _TabStrip = new SCSWeb.TabStrip();

            #if VERSION4
            _TabStrip.ViewStateMode = ViewStateMode.Enabled;
            #endif

            _TabStrip.TabItemClicked += new SCSWeb.TabStrip.ItemClickedHandler(TabStrip_TabItemClicked);
            container.Controls.Add(_TabStrip);

            // create a multiview to store the tab contents
            _TabMultiView = new MultiView();
            container.Controls.Add(_TabMultiView);

            // collect list of categories from the columns
            ListOfTabs = "Main";
            foreach (DataColumn dc in _dccol)
                if (ListOfTabs.IndexOf(dc.Namespace) < 0)
                    ListOfTabs = string.Format("{0},{1}", ListOfTabs, dc.Namespace);

            // create menu items as tabs
            string[] strTabs = ListOfTabs.Split(',');
            //_Tabs = new List<View>(strTabs.Length);

            foreach (string strCategory in strTabs)
            {
                // add tab to tabstrip
                SCSWeb.TabItem objTab = new SCSWeb.TabItem();
                objTab.Text = strCategory;
                objTab.Tag = strCategory;
                _TabStrip.Items.Add(objTab);

                // add corresponding view
                View objTabView = new View();
                objTabView.ID = strCategory;
                //_Tabs.Add(objTabView);
                _TabMultiView.Controls.Add(objTabView);

                // create a table within the view
                Table tbl = new Table();
                tbl.CssClass = CssClassTable;
                TableRow tr = null;
                TableCell td = null;

                objTabView.Controls.Add(tbl);

                int iColNbr = 0;
                foreach (DataColumn dc in _dccol)
                {
                    if (dc.ColumnName != null && dc.Namespace == strCategory )
                    {
                        iColNbr++;
                        // if there are more than the given nbr of rows, start adding columns instead of rows
                        // making the formview grow sideways instead of downward
                        if (iColNbr > NbrRows)
                            // add columns starting from first row on
                            tr = tbl.Rows[ ( iColNbr - 1 ) % NbrRows ];
                        else
                        {
                            tr = new TableRow();
                            tr.BorderWidth = Unit.Pixel(0);
                            tr.VerticalAlign = VerticalAlign.Top;
                            tbl.Rows.Add(tr);
                        }

                        // for each DataColum create a TableRow with 2 cells
                        td = new TableCell();
                        td.Wrap = false;
                        tr.Cells.Add(td);

                        td.Text = FormatColumnName(dc.ColumnName) + ":";
                        td.CssClass = CssClassTableCell;

                        td = new TableCell();
                        td.Wrap = false;
                        tr.Cells.Add(td);

                        CreateColumnControl(td, dc);
                    }
                }
            }

            // make the first tab selected
            _TabStrip.Items[0].Selected = true;
            _TabMultiView.SetActiveView(_TabMultiView.Views[0]);

            if (_type == ListItemType.Item)
            {
                LinkButton lnkEdit = new LinkButton();
                lnkEdit.Text = "Edit";
                lnkEdit.ToolTip = "Click here to turn on the EditItemTemplate of the FormView";
                lnkEdit.CommandName = "Edit";
                container.Controls.Add(lnkEdit);
            }
            else
            {
                // create a table to hold the link buttons
                Table tbl = new Table();
                tbl.CssClass = CssClassTable;
                TableRow tr = new TableRow();
                TableCell td = new TableCell();

                LinkButton lnkButton = new LinkButton();
                lnkButton.Text = "Cancel";
                lnkButton.ToolTip = "Click here to cancel the Edit process";
                lnkButton.CommandName = "Cancel";
                lnkButton.CausesValidation = false;
                td.Controls.Add(lnkButton);
                tr.Controls.Add(td);

                td = new TableCell();
                lnkButton = new LinkButton();
                lnkButton.Text = "Update";
                lnkButton.ToolTip = "Click here to update the record";
                lnkButton.CommandName = "Update";
                lnkButton.CausesValidation = false;
                td.Controls.Add(lnkButton);
                tr.Controls.Add(td);

                tbl.Controls.Add(tr);
                container.Controls.Add(tbl);
            }
        }
        void IStateManager.LoadViewState(object savedState)
        {
            if (savedState == null)
            {
                return;
            }

            if (savedState is Pair)
            {
                // All items were saved.
                // Create new TabItem collection using view state.
                _saveAll = true;
                Pair p = (Pair)savedState;
                ArrayList types = (ArrayList)p.First;
                ArrayList states = (ArrayList)p.Second;
                int count = types.Count;

                _tabItems = new ArrayList(count);
                for (int i = 0; i < count; i++)
                {
                    TabItem tabItem = null;
                    if (((char)types[i]).Equals('c'))
                        //{
                        tabItem = new TabItem();
                    //}
                    //else
                    //{

                    //}
                    Add(tabItem);
                    ((IStateManager)tabItem).LoadViewState(states[i]);
                }
            }
            else
            {
                // Load modified items.
                Triplet t = (Triplet)savedState;
                ArrayList indices = (ArrayList)t.First;
                ArrayList types = (ArrayList)t.Second;
                ArrayList states = (ArrayList)t.Third;

                for (int i = 0; i < indices.Count; i++)
                {
                    int index = (int)indices[i];
                    if (index < this.Count)
                    {
                        ((IStateManager)_tabItems[index]).LoadViewState(states[i]);
                    }
                    else
                    {
                        TabItem tabItem = null;
                        //if (((char)types[i]).Equals('c'))
                        //{
                        tabItem = new TabItem();
                        //}
                        //else
                        //{

                        //}
                        Add(tabItem);
                        ((IStateManager)tabItem).LoadViewState(states[i]);
                    }
                }
            }
        }
        public void Insert(int index, TabItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            _tabItems.Insert(index, item);

            if (_isTrackingViewState)
            {
                ((IStateManager)item).TrackViewState();
                _saveAll = true;
            }
        }
 public int IndexOf(TabItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     return _tabItems.IndexOf(item);
 }
 public bool Contains(TabItem item)
 {
     if (item == null)
     {
         return false;
     }
     return _tabItems.Contains(item);
 }
        public int Add(TabItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            _tabItems.Add(item);

            if (_isTrackingViewState)
            {
                ((IStateManager)item).TrackViewState();
                item.SetDirty();
            }

            return _tabItems.Count - 1;
        }