I have a DropDownList declared like this:
<asp:DropDownList ID="campaignTypeList" runat="server" Width="150px" DataTextField="Name" DataValueField="CampaignTypeId" DataSourceID="campaignTypesDataSource" SelectedValue='<%# Bind("CampaignTypeID") %>'>
</asp:DropDownList>
Using the designer, my SqlDataSource is configured as follows1:
<asp:SqlDataSource ID="campaignDataSource" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:ProVantageMediaManagement %>" SelectCommand="ActivationCampaignGetById"
SelectCommandType="StoredProcedure" UpdateCommand="ActivationCampaignUpdate" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="98" Name="campaignId" Direction="Input" QueryStringField="id" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:QueryStringParameter DefaultValue="98" Name="campaignId" Direction="Input" QueryStringField="id" Type="Int32" />
<asp:Parameter Name="campaignName" Type="String" />
<asp:Parameter Name="campaignTypeId" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Yet when the update command is sent to the DB, the campaignTypeId
value is always 1, no matter which item is selected in the DropDownList. What am I doing wrong?
1 Bonus points for telling us what a ControlParameter is meant for, if not for handling values of controls in a scenario like this.
ADDED: I created a new form, and posted all the markup from the old form onto it, and it just works. I assume there was some shady deal going on in the Designer.cs file or something. I did convert this project from a website to a web application.