Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
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);
        }

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.
Posted
Updated 18-Dec-10 19:36pm
v2
Comments
AspDotNetDev 19-Dec-10 1:47am    
Does Visual Studio tell you which line the exception occurs on?
Abdul Rahman Hamidy 19-Dec-10 3:07am    
this is the error i am getting.
"Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element
ScriptResourc.axd line 4621 char 23 Code 0"
Abhinav S 19-Dec-10 10:49am    
What line in the source code - your source code does not have line nos?

1 solution

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 [^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900