DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 07 Aug 2007 19:35:03 -0000,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Jason


dropdownlist has a selectedvalue which is invalid because it does not exist in the list of items.   
I'm trying to use a databound dropdown list in a grid view.  I can't
seem to get this to work.  If I Bind on a text box it works fine.
Otherwise I get the error below

'ddlDisplayArt' has a SelectedValue which is invalid because it does
not exist in the list of items.
Parameter name: value
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 'ddlDisplayArt'
has a SelectedValue which is invalid because it does not exist in the
list of items.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.

Stack Trace:


[ArgumentOutOfRangeException: 'ddlDisplayArt' has a SelectedValue
which is invalid because it does not exist in the list of items.
Parameter name: value]
 
System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable
dataSource) +1822067
   System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)
+104
   System.Web.UI.WebControls.ListControl.PerformSelect() +31
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   System.Web.UI.Control.DataBindChildren() +216
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +216
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32
dataSourceIndex, DataControlRowType rowType, DataControlRowState
rowState, Boolean dataBind, Object dataItem, DataControlField[]
fields, TableRowCollection rows, PagedDataSource pagedDataSource) +221
   System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding) +3004
 
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable
data) +59
   System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable
data) +11
 
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable
data) +111
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
arguments, DataSourceViewSelectCallback callback) +29
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
+82
 
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
+69
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +41
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1360


Here's the code

<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master"
AutoEventWireup="true" CodeFile="ManageArtists.aspx.cs"
Inherits="Admin_ManageArtists" Title="Turning Point Gallery - Artist
Administration" StylesheetTheme="Admin_Theme" %>
<asp:Content ID="cntMain" ContentPlaceHolderID="cphMain"
Runat="Server">
<asp:ObjectDataSource ID="odsArtists"
TypeName="TurningPointGalleryTableAdapters.ArtistTableAdapter"
runat="server"
	SelectMethod="GetArtists" UpdateMethod="Update" DeleteMethod="Delete"
InsertMethod="Insert"
	OldValuesParameterFormatString="original_{0}"   >
	<InsertParameters>
		<asp:Parameter Name="FirstName" Type="string" />
		<asp:Parameter Name="LastName" Type="string" />
		<asp:Parameter Name="DisplayName" Type="string" />
		<asp:Parameter Name="Profile" Type="string" />
		<asp:Parameter Name="DisplayArtId" Type="int32" />
	</InsertParameters>
	<UpdateParameters>
		<asp:Parameter Name="Original_ArtistId" Type="Int32" />
		<asp:Parameter Name="ArtistId" Type="int32" />
		<asp:Parameter Name="FirstName" Type="string" />
		<asp:Parameter Name="LastName" Type="string" />
		<asp:Parameter Name="DisplayName" Type="string" />
		<asp:Parameter Name="Profile" Type="string" />
		<asp:Parameter Name="DisplayArtId" Type="int32" />
	</UpdateParameters>
	<DeleteParameters>
		<asp:Parameter Name="Original_ArtistId" Type="int32" />
	</DeleteParameters>
</asp:ObjectDataSource>

<asp:ObjectDataSource ID="odsAllArtwork"
TypeName="TurningPointGalleryTableAdapters.ArtworkTableAdapter"
runat="server" SelectMethod="GetArtwork" />

<asp:ObjectDataSource ID="odsArtwork"
TypeName="TurningPointGalleryTableAdapters.ArtworkTableAdapter"
	runat="server" SelectMethod="GetArtworkByArtistId"
InsertMethod="Insert" UpdateMethod="Update" DeleteMethod="Delete"
	OldValuesParameterFormatString="original_{0}">
	<SelectParameters>
		<asp:ControlParameter Name="ArtistId" ControlID="grdArtists"
PropertyName="SelectedValue" />
	</SelectParameters>
	<InsertParameters>
		<asp:Parameter Name="ImageURL" Type="string" />
		<asp:Parameter Name="Title" Type="string" />
		<asp:Parameter Name="Height" Type="int32" />
		<asp:Parameter Name="Width" Type="int32" />
		<asp:Parameter Name="Depth" Type="int32" />
		<asp:Parameter Name="Blurb" Type="string" />
		<asp:Parameter Name="ArtistId" Type="int32" />
	</InsertParameters>
	<UpdateParameters>
		<asp:Parameter Name="ArtworkId" Type="Int32" />
		<asp:Parameter Name="Original_ArtworkId" Type="Int32" />
		<asp:Parameter Name="ImageURL" Type="string" />
		<asp:Parameter Name="Title" Type="string" />
		<asp:Parameter Name="Height" Type="int32" />
		<asp:Parameter Name="Width" Type="int32" />
		<asp:Parameter Name="Depth" Type="int32" />
		<asp:Parameter Name="Blurb" Type="string" />
		<asp:Parameter Name="ArtistId" Type="int32" />
	</UpdateParameters>
	<DeleteParameters>
		<asp:Parameter Name="Original_ArtworkId" Type="Int32" />
	</DeleteParameters>
</asp:ObjectDataSource>


<asp:Label CssClass="sectionHeader" ID="lblArtists"
runat="server">Artists</asp:Label>
<asp:GridView ID="grdArtists" DataSourceID="odsArtists" runat="server"
AutoGenerateColumns="False"
	OnRowCommand="grdArtists_RowCommand" DataKeyNames="ArtistId"
AllowSorting="True"
OnSelectedIndexChanged="grdArtists_SelectedIndexChanged" >
	<Columns>
			<asp:CommandField ShowInsertButton="True" ShowEditButton="True"
ShowDeleteButton="True" ShowSelectButton="True" />
			<asp:BoundField DataField="ArtistId" HeaderText="Artist Id"
SortExpression="ArtistId" />
			<asp:BoundField DataField="FirstName" HeaderText="First Name"
SortExpression="FirstName" />
			<asp:BoundField DataField="LastName" HeaderText="Last Name"
SortExpression="LastName" />
			<asp:BoundField DataField="DisplayName" HeaderText="Display Name"
SortExpression="DisplayName" />
			<asp:BoundField DataField="Profile" HeaderText="Profile"
SortExpression="Profile" />
			<asp:BoundField DataField="DisplayArtId" HeaderText="DisplayArtId"
SortExpression="DisplayArtId" Visible="False" />
<%-- THIS WORKS --%>
			<%--<asp:TemplateField>
				<ItemTemplate>
					<asp:TextBox ID="textbox1" Text='<%# Bind("DisplayArtId") %>'
runat="server" />
				</ItemTemplate>
				<EditItemTemplate>
					<asp:TextBox ID="textbox1" Text='<%# Bind("DisplayArtId") %>'
runat="server" />
				</EditItemTemplate>
			</asp:TemplateField>--%>

<%-- THIS DOES NOT --%>
			<asp:TemplateField HeaderText="Display Art"
SortExpression="DisplayArtId">
				<EditItemTemplate>
					<asp:DropDownList ID="ddlDisplayArt" AppendDataBoundItems="True"
SelectedValue='<%# Bind("DisplayArtID") %>'
DataSourceID="odsAllArtwork" DataValueField="ArtworkId"
Enabled="true"  DataTextField="Title" runat="server" >
						<asp:ListItem Text="None" Value="0" />
					</asp:DropDownList>
				</EditItemTemplate>
				<ItemTemplate>
					<asp:DropDownList ID="ddlDisplayArt" AppendDataBoundItems="True"
SelectedValue='<%# Bind("DisplayArtID") %>'
DataSourceID="odsAllArtwork" DataValueField="ArtworkId"
Enabled="false" DataTextField="Title" runat="server" >
						<asp:ListItem Text="None" Value="0" />
					</asp:DropDownList>
				</ItemTemplate>
			</asp:TemplateField>
	</Columns>
<EmptyDataTemplate>
	<asp:DetailsView ID="dtlArtists" DataSourceID="odsArtists"
runat="server" AutoGenerateInsertButton="false"
AutoGenerateRows="false"
		DefaultMode="Insert" OnItemInserted="dtlArtists_ItemInserted"
DataKeyNames="ArtistId" OnModeChanged="dtlArtists_ModeChanged">
		<Fields>
			<asp:BoundField DataField="FirstName" HeaderText="First Name"
SortExpression="FirstName" />
			<asp:BoundField DataField="LastName" HeaderText="Last Name"
SortExpression="LastName" />
			<asp:BoundField DataField="DisplayName" HeaderText="Display Name"
SortExpression="DisplayName" />
			<asp:BoundField DataField="Profile" HeaderText="Profile"
SortExpression="Profile" />
			<asp:BoundField DataField="DisplayArtId" HeaderText="Display Art
Id" SortExpression="DisplayArtId" />
			<asp:CommandField ShowCancelButton="true" ShowInsertButton="true" /

>

		</Fields>
	</asp:DetailsView>
</EmptyDataTemplate>
</asp:GridView>

<asp:Label CssClass="sectionHeader" ID="lblArtwork"
runat="server">Artwork</asp:Label>
<asp:GridView ID="grdArtwork" DataSourceID="odsArtwork" runat="server"
AutoGenerateColumns="false"
	OnRowCommand="grdArtwork_RowCommand" DataKeyNames="ArtworkId"
AllowSorting="True" Visible="false">
		<Columns>
		<asp:CommandField ShowInsertButton="true" ShowEditButton="true"
ShowDeleteButton="true" ShowSelectButton="True" />
			<asp:BoundField DataField="ArtworkId" HeaderText="Artwork Id"
SortExpression="ArtworkId" />
			<asp:BoundField DataField="ImageURL" HeaderText="Image URL"
SortExpression="ImageURL" />
			<asp:BoundField DataField="Title" HeaderText="Artwork Title"
SortExpression="Title" />
			<asp:BoundField DataField="Height" HeaderText="Height"
SortExpression="Height" />
			<asp:BoundField DataField="Width" HeaderText="Width"
SortExpression="Width" />
			<asp:BoundField DataField="Depth" HeaderText="Depth"
SortExpression="Depth" />
			<asp:BoundField DataField="Blurb" HeaderText="Blurb"
SortExpression="Blurb" />
			<asp:BoundField DataField="ArtistId" HeaderText="Artist Id"
SortExpression="ArtistId" />
		</Columns>
<EmptyDataTemplate>
	<asp:DetailsView ID="dtlArtwork" runat="server"
DataSourceID="odsArtwork"
		DefaultMode="Insert"  OnItemInserted="dtlArtwork_ItemInserted"
OnModeChanged="dtlArtwork_ModeChanged" DataKeyNames="ArtworkId"
AutoGenerateRows="false" >
		<Fields>
			<asp:BoundField DataField="ImageURL" HeaderText="Image URL"
SortExpression="ImageURL" />
			<asp:BoundField DataField="Title" HeaderText="Artwork Title"
SortExpression="Title" />
			<asp:BoundField DataField="Height" HeaderText="Height"
SortExpression="Height" />
			<asp:BoundField DataField="Width" HeaderText="Width"
SortExpression="Width" />
			<asp:BoundField DataField="Depth" HeaderText="Depth"
SortExpression="Depth" />
			<asp:BoundField DataField="Blurb" HeaderText="Blurb"
SortExpression="Blurb" />
			<asp:BoundField DataField="ArtistId" HeaderText="Artist Id"
SortExpression="ArtistId" />
			<asp:CommandField ShowCancelButton="true" ShowInsertButton="true" /

>

		</Fields>
	</asp:DetailsView>
</EmptyDataTemplate>
</asp:GridView>
</asp:Content>
Date:Tue, 07 Aug 2007 19:35:03 -0000   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us