/// <summary>
        /// Handles the data binding.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void HandleDataBinding( object sender, EventArgs e )
        {
            Control ctrl = (Control)sender;
            object val = GetValue( ctrl.NamingContainer ) ?? string.Empty;

            if ( data == null )
            {
                //Cache the data from the DataSourceControl, so that we only get the data once.  If
                //we just set the DataSourceID on the dropdown, the select command would get called
                //once for each row.
                DataSourceControl dsc = this.Control.NamingContainer.FindControl( this.DataSourceID ) as DataSourceControl;
                DataSourceView dsv = ( (IDataSource)dsc ).GetView( "DefaultView" );
                dsv.Select( DataSourceSelectArguments.Empty, new DataSourceViewSelectCallback( this.DataSourceCallback ) );
            }

            if ( ctrl is EntityDropDownList )
            {
                EntityDropDownList eddl = (EntityDropDownList)ctrl;
                eddl.DataTextField = this.DataTextField;
                eddl.DataValueField = this.DataValueField;
                eddl.DataSource = this.data;
                eddl.AppendNullItem = this.AppendNullItem;
            }
            else if ( ctrl is Label )
            {
                Label label = (Label)ctrl;
                EntityDropDownList temp = new EntityDropDownList();
                temp.DataTextField = this.DataTextField;
                temp.DataValueField = this.DataValueField;
                temp.DataSource = this.data;
                temp.Visible = false;
                temp.AppendNullItem = this.AppendNullItem;
                label.Controls.Add( temp );
                temp.DataBind();

                label.Text = String.Empty;
                foreach ( ListItem listItem in temp.Items )
                {
                    if ( 0 == String.Compare( listItem.Value, val.ToString() ) )
                    {
                        label.Text = listItem.Text;
                    }
                }
            }
        }
        /// <summary>
        /// Initializes the specified <see cref="T:System.Web.UI.WebControls.TableCell"></see> object to the specified row state.
        /// </summary>
        /// <param name="cell">The <see cref="T:System.Web.UI.WebControls.TableCell"></see> to initialize.</param>
        /// <param name="rowState">One of the <see cref="T:System.Web.UI.WebControls.DataControlRowState"></see> values.</param>
        protected override void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState)
        {
            if((!this.ReadOnly && (0!= (rowState & DataControlRowState.Edit)))
                || 0 != (rowState & DataControlRowState.Insert))
            {
                EntityDropDownList eddl = new EntityDropDownList();
                eddl.ToolTip = this.HeaderText;
                eddl.AppendNullItem = this.AppendNullItem;

                if (!String.IsNullOrEmpty(this.DataField) && 0 != (rowState & DataControlRowState.Edit))
                {
                    eddl.DataBinding += new EventHandler(HandleDataBinding);
                    eddl.DataBound += new EventHandler(HandleDataBound);
                }

                cell.Controls.Add(eddl);
            }
            else if (!String.IsNullOrEmpty(this.DataField))
            {
                Label label = new Label();
                label.DataBinding += new EventHandler(HandleDataBinding);
                cell.Controls.Add(label);
            }
        }