public void RefreshItem(int dataItemIndex)
        {
            // set the datasource position
            IOSList rl = DataSource;

            rl.SetPosition(dataItemIndex);
            SelectedIndex = dataItemIndex;

            // databind the correspondent datagriditem
            int             controlIndex = GetItemControlIndex(dataItemIndex);
            OSDataGridTable child        = (OSDataGridTable)Controls[0];
            OSDataGridItem  item         = (OSDataGridItem)child.Rows[controlIndex];

            // initialize item
            item.DataItem = rl.Current;
            InitializeItem(item, false);
            item.DataBind();
        }
        /// <summary>
        /// Inserts an item to the datagrid
        /// </summary>
        /// <param name="param name="dataItemIndex"></param>
        /// <param name="dataItem"></param>
        public void InsertItem(int dataItemIndex, object dataItem)
        {
            // check if the current page is full
            IOSList rl = DataSource;

            // update the datasource
            rl.Insert(dataItem, dataItemIndex);

            // set the record list position and databind the item
            rl.SetPosition(dataItemIndex);

            // create an item at the end of the list
            OSDataGridItem        item = (OSDataGridItem)CreateItem(dataItemIndex, dataItemIndex, ListItemType.Item);
            DataGridItemEventArgs e    = new DataGridItemEventArgs(item);

            // initialize item
            item.DataItem = dataItem;
            InitializeItem(item, true);
            this.OnItemCreated(e);

            OSDataGridTable child = (OSDataGridTable)Controls[0];

            // remove any empty message row...
            if (((OSDataGridItem)child.Rows[child.Rows.Count - 1]).IsEmptyMessageItem)
            {
                child.Rows.RemoveAt(child.Rows.Count - 1);
            }

            // insert the item before the footer and pager items
            int footerIndex = child.Rows.Count - 2;

            int footerId;

            if (child.Rows[footerIndex].ID != null)
            {
                footerId = OSDataGridItem.GetIntegerId(child.Rows[footerIndex].ID, EnableLegacyRendering);
            }
            else
            {
                footerId = footerIndex + 1;
            }

            child.Rows.AddAt(footerIndex, item);

            // generate a new item id for this control
            int id = footerId;

            item.ID = OSDataGridItem.FormatId(id, EnableLegacyRendering);

            // increase the footer and pager items, so that no repateated ids exist in the page
            child.Rows[child.Rows.Count - 2].ID = OSDataGridItem.FormatId(id + 1, EnableLegacyRendering);
            child.Rows[child.Rows.Count - 1].ID = OSDataGridItem.FormatId(id + 2, EnableLegacyRendering);

            ViewState["_!ItemCount"] = rl.Length;
            _isEmpty = false;

            // increase higher item indexes in the data grid
            foreach (OSDataGridItem otherItem in child.Rows)
            {
                if (otherItem.ItemIndex >= dataItemIndex && otherItem != item)
                {
                    otherItem.SetItemIndex(otherItem.ItemIndex + 1);
                }
            }

            // update row ids in the viewstate
            StoreViewStateRowIdsandItemIndexes();

            SelectedIndex = dataItemIndex;

            item.DataBind();
            this.OnItemDataBound(e);

            item.DataItem = null;
        }