[Mono-list] I can not call the function CreateChildControls ()

demendezr demendezr at gmail.com
Thu Jan 24 19:26:28 UTC 2013


Greetings, happens I need to create a table-type control and for that, I need
to call the function CreateChildControls and add a code, but Mono can not
directly call that function, some research says to call the function
EnsureChildControls (), but I do not know how to do that. Help me please, I
leave my CreateChildControls function ():


protected override int CreateChildControls(System.Collections.IEnumerable
dataSource, bool dataBinding)
        {
            int numRows = base.CreateChildControls(dataSource, dataBinding);

            //no data rows created, create empty table if enabled
            if (numRows == 0 && ShowEmptyTable)
            {
                //create table
                Table table = new Table();
				table.ID = this.ID;
                //create a new header row
                GridViewRow row = base.CreateRow(-1, -1,
DataControlRowType.Header, DataControlRowState.Normal);
                //convert the exisiting columns into an array and initialize
                DataControlField[] fields = new
DataControlField[this.Columns.Count];

				this.Columns.CopyTo(fields, 0);
                this.InitializeRow(row, fields);
				table.Rows.Add(row);
								       	
				         
                if (EmptyTableRowText.Trim() != "")
                {
                    GridViewRow row2 = new GridViewRow(-1, -1,
DataControlRowType.DataRow, DataControlRowState.Normal);
                    TableCell cell = new TableCell();
                    cell.ColumnSpan = this.Columns.Count;
                    cell.Width = Unit.Percentage(100);
                    cell.Controls.Add(new
LiteralControl(EmptyTableRowText));
                    row2.Cells.Add(cell);
                    table.Rows.Add(row2);

                }
                if (this.ShowFooter)
                {
                    //create a new footer row
                    GridViewRow row3 = base.CreateRow(-1, -1,
DataControlRowType.Footer, DataControlRowState.Normal);
                    this.InitializeRow(row3, fields);
                    table.Rows.Add(row3);
                }

                
                this.Controls.Add(table);

            }

            return numRows;
        }




--
View this message in context: http://mono.1490590.n4.nabble.com/I-can-not-call-the-function-CreateChildControls-tp4658274.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list