Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:42:12+00:00 2026-06-05T17:42:12+00:00

When I call DataBind() on a DropDownList in ASP.NET 4, it’s throwing an ArgumentNullException:

  • 0

When I call DataBind() on a DropDownList in ASP.NET 4, it’s throwing an ArgumentNullException:

System.ArgumentNullException: Value cannot be null. Parameter name:
container at System.Web.UI.DataBinder.GetPropertyValue(Object
container, String propName) at
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName, String format) at
System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable
dataSource) at
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) at
System.Web.UI.WebControls.ListControl.PerformSelect() at
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at
MyNamespace.MyClass.MyFunction()

Here is my code:

myDropdown.Items.Clear();
myDropdown.ClearSelection();
myDropdown.Items.Add(new ListItem("-Select-", "-1"));
myDropdown.DataSource = myDataSource; //List<T> of my business objects
myDropdown.DataBind();

I found this forum post that seems to suggest taking away the DataValueField and DataTextField settings on the dropdown, which I’ve set in markup. When I do that and change the second-to-last line of my code to this so I still get meaningful text in the options:

myDropdown.DataSource = myDataSource.Select(elem => new ListItem(elem.Text, elem.Id));

…it still doesn’t work. It does work, though, when I take away the line that adds the “-Select-” option. And it only breaks when there is no element selected before it’s data bound.

What’s going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:42:13+00:00Added an answer on June 5, 2026 at 5:42 pm

    Further Google searching found this other post that suggests that null objects in the datasource can cause this problem. I changed my DataSource line to this:

    myDropdown.DataSource = myDataSource.Where(elem => elem != null);
    

    And it worked.

    I have yet to determine why/how I have null values in that list. Hmm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ASP.NET, you can bind controls individually (i.e. GridView1.DataBind() ) or you can call
I'm using asp.net grid view. I call some sql-server stored procedure and attach it
The query does not return value when I call it from ASP C# however
Why method FindControl() returns null on FormView until call DataBind() . After that it
I have a button on an ASP.Net page that will call Response.Redirect back to
Why is there a need to explicitly call GridView.DataBind() to render the gridview. Why
I call this a flash meeting, but maybe there is another more appropriate name.
I have a problem regarding to asp.net lifecylce hierarchy. Basically, I have one user
Would a call to a database be called if you put the databind method
within an asp.net webform project I have a session variable that I am populating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.