private void InitializeItem(DataGridItem item, DataGridColumn[] columns, bool rowDatabinding, bool recreateChildControls)
        {
            if (rowDatabinding)
            {
                switch (item.ItemType)
                {
                case ListItemType.Header:
                    if (HeaderRowDataBinding != null)
                    {
                        HeaderRowDataBinding(item, null);
                    }
                    break;

                case ListItemType.Item:
                case ListItemType.AlternatingItem:
                    if (DataRowDataBinding != null)
                    {
                        DataRowDataBinding(item, null);
                    }
                    break;

                default:
                    break;
                }
            }

            if (recreateChildControls)
            {
                item.Cells.Clear();

                TableCellCollection cells = item.Cells;
                for (int i = 0; i < columns.Length; i++)
                {
                    System.Web.UI.WebControls.TableCell cell;
                    if (item.ItemType == ListItemType.Header)
                    {
                        cell = new OSDataGridTableHeaderCell();
                    }
                    else
                    {
                        cell = new OSDataGridTableCell();
                    }
                    cell.CssClass = getCellClass(item);
                    columns[i].InitializeCell(cell, i, item.ItemType);
                    cells.Add(cell);
                }
            }
        }
        /// <summary>
        /// Adds the empty row item if necessary
        /// </summary>
        private void AddEmptyRow()
        {
            bool any = false;

            foreach (OSDataGridItem item in this.Controls[0].Controls)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    any = true;
                    break;
                }
            }
            if (!any)
            {
                _isEmpty = true;
                // add empty row...
                OSDataGridItem dataGridItem = new OSDataGridItem(0, 0, ListItemType.Item);

                // mark this as empty message item
                dataGridItem.IsEmptyMessageItem = true;
                OSDataGridTableCell tableCell = new OSDataGridTableCell();
                tableCell.ColumnSpan = TotalColumnSpan;
                tableCell.CssClass   = OddLineStyle;

                tableCell.Text = EmptyMessage;
                dataGridItem.Cells.Add(tableCell);

                OSDataGridTable child = (OSDataGridTable)Controls[0];
                child.Rows.Add(dataGridItem);
                // Making the id item ok based on the number of elements
                dataGridItem.ID = OSDataGridItem.FormatId(child.Rows.Count, EnableLegacyRendering);
            }
            else
            {
                _isEmpty = false;
            }
        }