Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

DropdownList error

$
0
0

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>

 

 


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>