在ASP.Net中动态创建ComboBox [英] Dynamically create ComboBox in ASP.Net

查看:83
本文介绍了在ASP.Net中动态创建ComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我正在使用下面的代码动态创建ComboBox.但是在页面加载中,我得到一个错误"Sys.ArgumentException:控件和行为"的值不能为null.参数名称:element ..."
我正在使用VS 2010和AJAX 4.0工具包.

Dear All,
I am using below code to create ComboBox dynamically. But in page load i am getting an error "Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element..."
I am using VS 2010 and AJAX 4.0 toolkit.

foreach (DataRow dR in dtCommitmentRowSource.Rows)
        {
            row = new TableRow();
            ddl = new AjaxControlToolkit.ComboBox();
            ddl.Visible = true;
            ddl.RenderMode = AjaxControlToolkit.ComboBoxRenderMode.Block;
            //1st Column
            cell = new TableCell();
            cell.CssClass = "tdVerticalHeader";
            cell.Text = string.Format("{0} Code", dR["LevelName"]);
            cell.HorizontalAlign = HorizontalAlign.Left;
            row.Cells.Add(cell);
            //2nd Column
            ddl.CssClass = "WindowStyle";
            ddl.ID = dR["LevelName"].ToString();
            ddl.DataSource = c.getCOACodesByCOAStructure(Convert.ToInt32(dR["RecordID"]));
            ddl.DataTextField = "Code";
            ddl.DataValueField = "RecordID";
            ddl.AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.SuggestAppend;
            ddl.AutoPostBack = true;
            ddl.DataBind();
            cell = new TableCell();
            cell.Width = new Unit(100, UnitType.Pixel);
            cell.CssClass = "tdsLevelTxs";
            cell.Controls.Add(ddl);
            row.Cells.Add(cell);
            //3rd Column
            cell = new TableCell();
            cell.CssClass = "tdsLevelTxs";
            cell.Text = "Code Desc Here";
            row.Cells.Add(cell);
            tbSubCommitment.Rows.Add(row);
            row = new TableRow();
            cell = new TableCell();
            cell.CssClass = "tdHorizentalEmpty";
            row.Cells.Add(cell);
            tbSubCommitment.Rows.Add(row);
        }


我发现ComboBox没有任何数据源.

我不知道错误"Sys.ArgumentException:控件和行为的值不能为null.参数名称:element ..." 的来源.


I found that the ComboBox does not get any datasource.

I dont know where the error "Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element..." comes from.

推荐答案

Excecption来自Microsoft AJAX和ASP.NET引擎

关于此的大量信息可用:
Sys.ArgumentException:值不能为空 [
The Excecption is coming from the Microsoft AJAX and ASP.NET engine

A plethora of information is available on this:
Sys.ArgumentException: Value must not be null [^]


这篇关于在ASP.Net中动态创建ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆