// create the property panel as a table. The panel contains each column // being prompted. private void CreatePropertyPanel(AcTable InPanel) { AcTableRow row; AcTableCell cell; string columnValue; DataRow rowrow = null; DataTable rowtbl = null; // create the property panel as a table. InPanel.AddStyle("background-color", "lightgrey") .AddStyle("font-family", "Verdana, Arial") .AddStyle("border-color", "white"); // first row holds the property panel title InPanel.AddNewRow().AddNewCell() .AddAttribute("ColSpan", "2") .AddStyle("text-align", "center") .SetText(Title); // build a dataset holding the single row to be prompted. if ((ActionCode != ActionCode.Add) && (RowSelect != null)) { DataSet rowds = TableRowToDataSet(); rowtbl = rowds.Tables[0]; rowrow = rowtbl.Rows[0]; } foreach (ColumnPrompt column in Columns) { // add a row to the panel grid for each column in the table row being prompted. // foreach ( DataColumn column in rowtbl.Columns ) // { string columnName = column.ColumnName; columnValue = null; // AcColumnInfo of the column. AcColumnInfo info = null; if ((ColumnInfo != null) && (ColumnInfo.ContainsKey(columnName))) { info = ColumnInfo[columnName]; } // get ColumnPrompt of this column. // ( either default or the entry from mColumns collection ) // if ( Columns.Count == 0 ) // cp = new ColumnPrompt( ColumnName ) ; // else // cp = FindColumnPrompt( ColumnName ) ; // if ( cp == null ) // continue ; // add an AcTableRow to the panel AcTable row = InPanel.AddNewRow(); // column prompt text string headingText = columnName; if ((info != null) && (info.HeadingText != null)) { headingText = info.HeadingText; } // first column is the column prompt text row.AddNewCell() .AddStyle("padding-right", "2%") .SetText(headingText); // second column is the column value. // Get the value from either the sql selected row ( see RowSelect property ) // or the InputColumnValues ColumnName/ColumnValue dictionary. cell = row.AddNewCell(); if (rowrow != null) { columnValue = rowrow[columnName].ToString(); } else if (mInputColumnValues != null) { columnValue = mInputColumnValues[columnName]; } if ((info != null) && (info.AllowedValues != null)) { DropDownList ddl = new DropDownList(); foreach (string alwvlu in info.AllowedValues) { ddl.Items.Add(alwvlu); } cell.Controls.Add(ddl); } else if (AlwChg == true) { TextBox tb = new TextBox(); tb.Text = columnValue; cell.Controls.Add(tb); } else { cell.AddStyle("padding-right", "1%") .SetText(columnValue); } } }
// create the property panel as a table. The panel contains each column // being prompted. private void CreateChildControls_Columns(Panel InPanel) { Label lbl = null; string columnValue; DataRow rowrow = null; DataTable rowtbl = null; // build a dataset holding the single row to be prompted. if ((ActionCode != ActionCode.Add) && (RowSelect != null)) { DataSet rowds = TableRowToDataSet(); rowtbl = rowds.Tables[0]; rowrow = rowtbl.Rows[0]; } foreach (KeyValuePair <string, AcColumnInfo> pair in Columns) { AcColumnInfo column = pair.Value; columnValue = null; // column prompt text string headingText = column.ColumnName; if (column.HeadingText != null) { headingText = column.HeadingText; } // the column prompt label. lbl = new Label(); InPanel.Controls.Add(lbl); lbl.Text = headingText; lbl.CssClass = PromptStyles.HeadingClass; // Get the value from either the sql selected row ( see RowSelect property ) // or the InputColumnValues ColumnName/ColumnValue dictionary. if (InitialLoadDone == true) { columnValue = null; } else { if (rowrow != null) { columnValue = rowrow[column.ColumnName].ToString(); } else if ((mInputColumnValues != null) && (mInputColumnValues.ContainsKey(column.ColumnName) == true)) { columnValue = mInputColumnValues[column.ColumnName]; } } // column has multiple allowed values. use DropDownList. if (column.HasAllowedValues == true) { DropDownList ddl = new DropDownList(); foreach (string alwvlu in column.AllowedValues) { ddl.Items.Add(alwvlu); } ddl.CssClass = PromptStyles.FieldClass; ddl.ID = column.ColumnName; if ((mFocusColumn != null) && (mFocusColumn == column.ColumnName)) { ddl.Focus(); } InPanel.Controls.Add(ddl); } // prompt the value in a TextBox. else { TextBox tb = new TextBox(); InPanel.Controls.Add(tb); tb.ID = column.ColumnName; tb.CssClass = PromptStyles.FieldClass; if (AlwChg == false) { tb.ReadOnly = true; } if ((mFocusColumn != null) && (mFocusColumn == column.ColumnName)) { tb.Focus(); } // apply the initial value if (InitialLoadDone == false) { tb.Text = columnValue; } } } // apply initial value to the controls one time only. InitialLoadDone = true; }