Hello all,
I am having a bit of a problem that others seem to have, but I can't find a clean answer for.
I have a DetailsView that when switched to edit mode displays a drop down list. I want this list to be populated with choices from another table. So, I have 2 object data sources. 1 for the DetailsView and 1 for the drop down list.
My problem is that when I try to set the selected value of the drop down list using a Bind expression to a column in the first table I get a
'EditOfficeDropDownList' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Error. When I remove the bind statement I see that all the correct choices are indeed there. I have tried setting AppendDataBoundFields to true on the DDL but that hasn't worked. What am I doing wrong?
Thanks!!
Code:
<aspetailsView ID="UserDetailsView" runat="server" AutoGenerateRows="False" DataKeyNames="UserName"
DataSourceID="UserDetailsViewDataSource" Height="50px" Width="300px" HeaderText="User Details" Visible="False" CommandRowStyle-HorizontalAlign="Left" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" GridLines="Horizontal">
<Fields>
<asp:TemplateField HeaderText="Office">
<EditItemTemplate>
<aspropDownList Width="150px" AppendDataBoundItems="true" ID="EditOfficeDropDownList" runat="server" DataSourceID="OfficesObjectDataSource" DataValueField="Name" DataTextField="Name" SelectedValue='<%# Bind("Office") %>'>
</aspropDownList>
</EditItemTemplate>
...
</asp:detailsview>
<asp:ObjectDataSource ID="UserGridViewObjectDataSource" runat="server" DeleteMethod="Delete"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetMembers" TypeName="MembershipUserODS"
UpdateMethod="Update" SortParameterName="sortData">
...
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="OfficesObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllOffices" TypeName="OfficesBLL"></asp:ObjectDataSource
I am having a bit of a problem that others seem to have, but I can't find a clean answer for.
I have a DetailsView that when switched to edit mode displays a drop down list. I want this list to be populated with choices from another table. So, I have 2 object data sources. 1 for the DetailsView and 1 for the drop down list.
My problem is that when I try to set the selected value of the drop down list using a Bind expression to a column in the first table I get a
'EditOfficeDropDownList' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Error. When I remove the bind statement I see that all the correct choices are indeed there. I have tried setting AppendDataBoundFields to true on the DDL but that hasn't worked. What am I doing wrong?
Thanks!!
Code:
<aspetailsView ID="UserDetailsView" runat="server" AutoGenerateRows="False" DataKeyNames="UserName"
DataSourceID="UserDetailsViewDataSource" Height="50px" Width="300px" HeaderText="User Details" Visible="False" CommandRowStyle-HorizontalAlign="Left" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" GridLines="Horizontal">
<Fields>
<asp:TemplateField HeaderText="Office">
<EditItemTemplate>
<aspropDownList Width="150px" AppendDataBoundItems="true" ID="EditOfficeDropDownList" runat="server" DataSourceID="OfficesObjectDataSource" DataValueField="Name" DataTextField="Name" SelectedValue='<%# Bind("Office") %>'>
</aspropDownList>
</EditItemTemplate>
...
</asp:detailsview>
<asp:ObjectDataSource ID="UserGridViewObjectDataSource" runat="server" DeleteMethod="Delete"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetMembers" TypeName="MembershipUserODS"
UpdateMethod="Update" SortParameterName="sortData">
...
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="OfficesObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllOffices" TypeName="OfficesBLL"></asp:ObjectDataSource