Creat WebCombo dynamically

2 replies. Last post: November 4, 2013 6:28 PM by luwen zhang
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
luwen zhangMember

Hi,

I am trying to create webcombo dynamically from code behind because I do not know how many webcombos there will be on the page.  I bind data from client side.  Here is the code on client. I got error at combo.Render(). 

<asp:Panel ID="pnlDynamic" runat="server"></asp:Panel>
        function BindWebCombo() {
                var webComboTable = new ISDataTable();
                var keyColumn = new ISDataColumn(webComboTable);
                var textColumn = new ISDataColumn(webComboTable);

                webComboTable.Name = webComboTable.TableName = "TaxCodesDesc";
                keyColumn.Name = keyColumn.ColumnName = "Key";
                textColumn.DataType = "System.Int32";
                textColumn.Name = textColumn.ColumnName = "Value";
                textColumn.DataType = "System.String";

                webComboTable.Columns.Add(keyColumn);
                webComboTable.Columns.Add(textColumn);

                for (var j = 0; j < 100; j++) {
                    var dataRow = webComboTable.NewRow();
                    dataRow.Cells.GetNamedItem("Key").Value = j;
                    dataRow.Cells.GetNamedItem("Value").Value = "item" + j.toString();
                    webComboTable.Rows.Add(dataRow);
                }

                for (var i = 1; i <= webComboCount; i++) {
                    combo = ISGetObject("WebCombo" + i.toString());
                    combo.SetDataSource(webComboTable);
                    combo.DataBind();
                    combo.Render();
                    combo.ShowDropDown();
                }            
        }

Here is code to create the web combo dynamically in code behind. Same webcombo setting works when setting statically.

        protected void CreateWebCombo(int webComboCount)
        {
            for (int i = 1; i <= webComboCount; i++)
            {
                WebCombo combo = new WebCombo("WebCombo" + i.ToString());
                combo.BindingOperationMode = ISNet.WebUI.BindingMode.ClientBinding;
                combo.DataValueField = "Key";
                combo.DataTextField = "Value";
                WebComboColumn comboColumn = new WebComboColumn("Description");
                comboColumn.BaseFieldName = "Value";
                comboColumn.DataType = "System.String";
                comboColumn.HeaderText = "Description";
                combo.LayoutSettings.EntryMode = EntryMode.AutoComplete;
                combo.LayoutSettings.StatusBoxVisible = false;
                combo.FlyPostBackSettings.PostHiddenFields = true;
                combo.FlyPostBackSettings.PostInputControls = true;
                combo.ClientBindingSettings.DataSourceType = ISNet.WebUI.ClientDataSourceType.ClientDataSource;
                
                pnlDynamic.Controls.Add(combo);

            }
        }

 Error message:

"Microsoft JScript runtime error: 'innerText' is null or not an object"

 

Thanks,

Luwen

All times are GMT -5. The time now is 10:12 AM.
Previous Next