I have an ObjectDataSource set up 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>
Within a FormView on the page, in the EditItemTemplate I have 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'm having is that when the UpdateAccount method in AccountBLL fires, the iPrimaryGroup field is always set to zero. If I examine the DropDownList for this, it appears to be functioning properly. For some reason, it's just not passing this one value back to the UpdateAccount function. It is not set to ReadOnly in the DataSet, and the correct value is selected in the DropDownList.
This was working fine a few hours ago, and it just suddenly stopped working for no explicable reason. I have another DropDownList control which is virtually identical that is working fine.
The only thing I can think of is that it's not happy that I'm pulling the data from a different ObjectDataSource for the DropDownList and attempting to Bind the value, but the same thing is happening in the other DropDownList and that one appears to be working properly.
Any ideas on how I might fix this? I've restarted Visual Studio several times. I've cleared my cache, I've rebuilt the solution, I've diff'd the code, and I've converted the DropDownList to a Label, but no dice.
Is there somewhere that I can force the two way binding to occur or a place I can look to see what the mappings are between the UpdateParameters and the FormView controls in the EditItemTemplate? I don't need to rename my field in the database to be iGroupID do I?
Everything appears to work fine except that the value for this one field isn't being passed to the function. Any help at all would be appreciated.
EDIT: It would appear that in the table row, if I take out runat="server", it starts working again. So, my revised question is: why? Is there a way around this?