Problem with non data bound value in ASP.NET DropDownList.
- by ProfK
I'm trying to 'inject' an [All Regions] item into my regions dropdown, as follows:
<asp:DropDownList ID="regionList" runat="server" AutoPostBack="true" AppendDataBoundItems="true" Width="200px" DataSourceID="regionDataSource" DataTextField="Desc"
DataValueField="RegionId">
<asp:ListItem Selected="True" Value="">[All Regions]</asp:ListItem>
</asp:DropDownList>
I also have a rank dropdown, for taxi ranks in a region, with the following select parameter:
<asp:ControlParameter ControlID="regionList" Name="RegionId" PropertyName="SelectedValue" Type="Int32" DefaultValue="" ConvertEmptyStringToNull="true" />
So the expected behaviour is that when [All Regions] is selected, the ranks dropdown should get a null parameter, and mt SQL selects all ranks, for all regions. I know my SQL works with a null parameter, but the ranks dropdown is not data binding when I select [All Regions] on the region list. It binds when I select a region from the DB, but keeps that binding when I select [All Regions] again. What am I doing wrong?