- Joined
- May 16, 2006
- Messages
- 1
- Reaction score
- 0
Hello,
Especially Phillip. I am desparately trying to implement cascading dropdowns with in a gridview. However I can not even get past the basics.
Here is the error I get. I am using the pubs database.
'ddlCountry' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Please advise. Thanks, far
Here is my code:
<asp:ObjectDataSource ID="odsPublishers" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetPublishers" TypeName="PubsTableAdapters.PublishersTableAdapter"></asp:ObjectDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="odsPublishers" AllowPaging="True" AllowSorting="True" DataKeyNames="pub_id">
<Columns>
<asp:TemplateField HeaderText="Commands">
<ItemTemplate>
<asp:LinkButton CommandName="Edit" ID="btnEdit" runat="server" Text="Edit"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton CommandName="Update" ID="btnUpdate" runat="server" Text="Update"></asp:LinkButton>
<asp:LinkButton CommandName="Cancel" ID="btnCancel" runat="server" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="pub_id" HeaderText="pub_id" ReadOnly="True" SortExpression="pub_id" />
<asp:BoundField DataField="pub_name" HeaderText="pub_name" SortExpression="pub_name" />
<asp:BoundField DataField="country" HeaderText="country" SortExpression="country" />
<asp:TemplateField HeaderText="Country">
<ItemTemplate>
<asp:Label ID="lblCountry" runat="server" Text='<%#Eval("Country") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:ObjectDataSource ID="odsCountry" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCountry" TypeName="PubsTableAdapters.pubCountryTableAdapter"></asp:ObjectDataSource>
<aspropDownList ID="ddlCountry" runat="server" DataSourceID="odsCountry" AutoPostBack="True"
SelectedValue='<%# Bind("Country") %>'>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="state" HeaderText="state" SortExpression="state" />
</Columns>
</asp:GridView>
Especially Phillip. I am desparately trying to implement cascading dropdowns with in a gridview. However I can not even get past the basics.
Here is the error I get. I am using the pubs database.
'ddlCountry' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Please advise. Thanks, far
Here is my code:
<asp:ObjectDataSource ID="odsPublishers" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetPublishers" TypeName="PubsTableAdapters.PublishersTableAdapter"></asp:ObjectDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="odsPublishers" AllowPaging="True" AllowSorting="True" DataKeyNames="pub_id">
<Columns>
<asp:TemplateField HeaderText="Commands">
<ItemTemplate>
<asp:LinkButton CommandName="Edit" ID="btnEdit" runat="server" Text="Edit"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton CommandName="Update" ID="btnUpdate" runat="server" Text="Update"></asp:LinkButton>
<asp:LinkButton CommandName="Cancel" ID="btnCancel" runat="server" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="pub_id" HeaderText="pub_id" ReadOnly="True" SortExpression="pub_id" />
<asp:BoundField DataField="pub_name" HeaderText="pub_name" SortExpression="pub_name" />
<asp:BoundField DataField="country" HeaderText="country" SortExpression="country" />
<asp:TemplateField HeaderText="Country">
<ItemTemplate>
<asp:Label ID="lblCountry" runat="server" Text='<%#Eval("Country") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:ObjectDataSource ID="odsCountry" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCountry" TypeName="PubsTableAdapters.pubCountryTableAdapter"></asp:ObjectDataSource>
<aspropDownList ID="ddlCountry" runat="server" DataSourceID="odsCountry" AutoPostBack="True"
SelectedValue='<%# Bind("Country") %>'>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="state" HeaderText="state" SortExpression="state" />
</Columns>
</asp:GridView>