P
P. Yanzick
Hello,
I am creating an edit template for a FormView control, changing one of the
textboxes to a dropdown box. The dropdown will be populated from a simple
table with the primary key, and a description (i.e. a colors table, so there
is a colors ID and a color description).
The data source the FormView is pulling data from stores (in this example)
the primary key for the colors table. My ultimate goal is when the FormView
goes into an Edit mode that the description of the color will be set
correctly based off of the ID provided in the record the FormView is
displaying. As an example, if the colors ID is 1, and that happens to be
blue, the dropdown will default to the value of blue.
I've been trying various ways to get this to work, and am not having much
luck. Is there an example somewhere that someone is aware of to show how to
do this? The error I keep getting is below. I'm thinking it has to do with
the order the controls bind, but I do not know for sure. Any suggestions
would be appreciated.
Thanks
Paul
'DropDownList1' 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: 'DropDownList1' 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: 'DropDownList1' 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) +975
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +80
System.Web.UI.WebControls.ListControl.PerformSelect() +32
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.Control.DataBind() +31
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.Control.DataBind() +31
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.Control.DataBind() +31
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.WebControls.FormView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding) +3047
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable
data) +90
System.Web.UI.WebControls.FormView.PerformDataBinding(IEnumerable data)
+30
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable
data) +126
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
DataSourceViewSelectCallback callback) +98
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +154
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
System.Web.UI.WebControls.FormView.DataBind() +23
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +91
System.Web.UI.WebControls.FormView.EnsureDataBound() +176
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
+101
System.Web.UI.Control.EnsureChildControls() +134
System.Web.UI.Control.PreRenderRecursiveInternal() +109
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4435
I am creating an edit template for a FormView control, changing one of the
textboxes to a dropdown box. The dropdown will be populated from a simple
table with the primary key, and a description (i.e. a colors table, so there
is a colors ID and a color description).
The data source the FormView is pulling data from stores (in this example)
the primary key for the colors table. My ultimate goal is when the FormView
goes into an Edit mode that the description of the color will be set
correctly based off of the ID provided in the record the FormView is
displaying. As an example, if the colors ID is 1, and that happens to be
blue, the dropdown will default to the value of blue.
I've been trying various ways to get this to work, and am not having much
luck. Is there an example somewhere that someone is aware of to show how to
do this? The error I keep getting is below. I'm thinking it has to do with
the order the controls bind, but I do not know for sure. Any suggestions
would be appreciated.
Thanks
Paul
'DropDownList1' 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: 'DropDownList1' 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: 'DropDownList1' 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) +975
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +80
System.Web.UI.WebControls.ListControl.PerformSelect() +32
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.Control.DataBind() +31
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.Control.DataBind() +31
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.Control.DataBind() +31
System.Web.UI.Control.DataBindChildren() +236
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +178
System.Web.UI.WebControls.FormView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding) +3047
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable
data) +90
System.Web.UI.WebControls.FormView.PerformDataBinding(IEnumerable data)
+30
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable
data) +126
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments,
DataSourceViewSelectCallback callback) +98
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +154
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
System.Web.UI.WebControls.FormView.DataBind() +23
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +91
System.Web.UI.WebControls.FormView.EnsureDataBound() +176
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
+101
System.Web.UI.Control.EnsureChildControls() +134
System.Web.UI.Control.PreRenderRecursiveInternal() +109
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4435