views:

17

answers:

1

Hi,

When I add AutoPostback = True to my DropDownList (with OnSelectedIndexChanged) I get a System.ArgumentNullException: Value cannot be null.

My control looks like this:

<asp:DropDownList ID="dropdown" runat="server" AutoPostBack="true"  OnSelectedIndexChanged="dropdown_OnSelectedIndexChanged" />

And code to fill control:

    dropdown.Items.Add(new ListItem("Item 1", "1"));
    dropdown.Items.Add(new ListItem("Item 2", "2"));
    dropdown.Items.Add(new ListItem("Item 3", "3"));

Update

I get the error when adding an empty page with the following code too:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_dev_test_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList AutoPostBack="true" ID="DropDownList1" runat="server" />
    </div>
    </form>
</body>
</html>
A: 

Solved the problem. A component I was using inside my web.config was causing the problem. So I added another web.config in the same category as the page using the faulty component and that solved the problem. (as long as I don't use AutoPostBack on that page ;))

Andreas