I have an ObjectDataSource configured as follows:
<asp:ObjectDataSource ID="AccountDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAccountByAccountID" TypeName="AccountBLL" InsertMethod="RegisterAccount" UpdateMethod="UpdateAccount">
<SelectParameters>
<asp:QueryStringParameter Name="iAccountID" QueryStringField="iAccountID" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="sAccountname" Type="String" />
<asp:Parameter Name="sPassword" Type="String" />
<asp:Parameter Name="sConfirmPassword" Type="String" />
<asp:Parameter Name="sEmailAddress" Type="String" />
<asp:Parameter Name="sConfirmEmailAddress" Type="String" />
<asp:Parameter Name="sDisplayName" Type="String" />
<asp:Parameter Name="sRealName" Type="String" />
<asp:Parameter Name="sSignature" Type="String" />
<asp:Parameter Name="iTimezone" Type="Int32" />
<asp:Parameter Name="iGuestAccountID" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="sAccountname" Type="String" />
<asp:Parameter Name="sPassword" Type="String" />
<asp:Parameter Name="sRealName" Type="String" />
<asp:Parameter Name="sDisplayName" Type="String" />
<asp:Parameter Name="sEmailAddress" Type="String" />
<asp:Parameter Name="sSignature" Type="String" />
<asp:Parameter Name="bIsActive" Type="Boolean" />
<asp:Parameter Name="iTimeZoneID" Type="Int32" />
<asp:Parameter Name="iPrimaryGroup" Type="Int32" />
<asp:Parameter Name="original_iAccountID" Type="Int32" />
</UpdateParameters> </asp:ObjectDataSource>
<asp:ObjectDataSource ID="GroupDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetGroups" TypeName="GroupBLL">
</asp:ObjectDataSource>
Inside the FormView on the page in EditItemTemplate, I declared the following:
<tr id="primaryGroupRow" runat="server">
<td class="Fieldname">Primary Group:</td>
<td><asp:DropDownList ID="iPrimaryGroupDropDownList" runat="server" DataSourceID="GroupDataSource" CssClass="PageText"
DataTextField="sGroupName" DataValueField="iGroupID" SelectedValue='<%# Bind("iPrimaryGroup") %>'></asp:DropDownList></td>
</tr>
The problem I am facing is that when running the UpdateAccount method in AccountBLL, the iPrimaryGroup field is always zero. If I consider DropDownList for this, it works fine. For some reason, it simply does not pass this value back to the UpdateAccount function. It is not set to ReadOnly in the DataSet, and the correct value is selected in the DropDownList.
, . DropDownList, , .
, , , , ObjectDataSource DropDownList , DropDownList, .
, ? Visual Studio. , , , DropDownList , .
-, , , , , UpdateParameters FormView EditItemTemplate? , iGroupID?
, , . .
EDIT: , , runat = "server", . , : ? ?