I get the following error when I try to assign a value to a dropdownlist: 'ddlRespondingVehicles' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
Code behind:
ddlRespondingVehicles.SelectedValue =Convert.ToString(dt2.Rows[0]["RespondingVehicle"]);
aspx page
<b>Responding Emergency Station</b><br/><asp:DropDownListID="ddlRespondingStations"runat="server"AppendDataBoundItems="true"AutoPostBack="true"Width="90%"Height="25px"DataSourceID="SqlDataSource1"DataTextField="StationName"DataValueField="ESSID"><asp:ListItemValue="0">Select Station</asp:ListItem></asp:DropDownList><asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ConnectionStrings:TheOneConnectionString%>"SelectCommand="SELECT [ESSID], [StationName] FROM [Station]"></asp:SqlDataSource></p><p><b>Responding Emergency Vehicles</b><br/><asp:DropDownListID="ddlRespondingVehicles"runat="server"AutoPostBack="true"Width="90%"Height="25px"DataSourceID="SqlDataSource2"AppendDataBoundItems="true"DataTextField="VehicleDesc"DataValueField="ESVID"><asp:ListItemSelected="True"Value="0">Select Station</asp:ListItem></asp:DropDownList><asp:SqlDataSourceID="SqlDataSource2"runat="server"ConnectionString="<%$ConnectionStrings:TheOneConnectionString%>"SelectCommand="SELECT [ESVID], [VehicleDesc] FROM [Vehicle] WHERE (([ESSID] = @ESSID) AND ([VehicleStatus] = @VehicleStatus))"><SelectParameters><asp:ControlParameterControlID="ddlRespondingStations"Name="ESSID"PropertyName="SelectedValue"Type="Decimal"/><asp:ParameterDefaultValue="1"Name="VehicleStatus"Type="Decimal"/></SelectParameters></asp:SqlDataSource>