Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 21st, 2006, 08:43 AM
Registered User
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Gridview - EditItemTemplate DropDownList issue

I have a gridview that includes an EditItemTemplate that uses a dropdown listbox that is bound to a dataset, instead of a textbox to get user input. When I click on the edit button I get the error message

'ddLocation' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

I have seen lots of comments on this in several onlne forums, but cannot seem to get it right. What code behind event would i use to check the dropdown list and place a default value to get around this issue? I included my asp code below.

<asp:AccessDataSource ID="dsLocations" runat="server" DataFile="~/App_Data/Corporate.mdb"
SelectCommand="SELECT [City] FROM [tblStores] ORDER BY [City]" ></asp:AccessDataSource>
<asp:DropDownList ID="ddLocation" runat="server" DataSourceID="dsLocations" DataTextField="City"
DataValueField="City" Width="192px" DataMember="DefaultView" SelectedValue='<%# Bind("Location") %>'>

<asp:Label ID="lblLocation" runat="server" Text='<%# Bind("Location") %>' Width="128px"></asp:Label>

David Pickart

Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList in Gridview sdoremus ASP.NET 3.5 Basics 0 September 15th, 2008 07:15 PM
Gridview bound dropdownlist edititemtemplate Bushwhacker ASP.NET 2.0 Basics 1 March 15th, 2008 07:35 PM
problem with dropdownlist in editItemTemplate hertendreef ASP.NET 2.0 Professional 4 July 31st, 2007 05:56 PM
Gridview and DropDownList extendedram ASP.NET 2.0 Basics 3 June 12th, 2007 04:05 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.