Update parameter not working on bound DropDownList
Posted
by ProfK
on Stack Overflow
See other posts from Stack Overflow
or by ProfK
Published on 2010-04-18T19:32:04Z
Indexed on
2010/04/18
19:33 UTC
Read the original article
Hit count: 305
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.
© Stack Overflow or respective owner