Index (zero based) must be greater than or equal to zero and less than the size of the argument list


Most of the time you get this error when you are trying to retrieve the selected value of a listbox (DropDownList) and no value is selected.

Even though apparently the first item in a DropDownList is always selected by default, this is done by the browser and ASP.NET is not aware of the selected item. To prevent this error from happening you need to define one of the items in your DropDownList as selected:

<asp:ListItem Value="1" Selected="True">Item 1</asp:ListItem>

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top