1
I cannot understand what is wrong. Dropdown is in a Formview of a user control. The dropdown links to a database table that should return 2 id and name values
Formview
<td><asp:DropDownList width="350px"
ID="EntregaRegiaoDropDownList" runat="server" SelectedValue='<%# Bind ("Regiao") %>' DataSourceID ="SqlDataSource1" DataTextField ="RegiaoNome" DataValueField ="RegiaoID" Enabled ="False"></asp:DropDownList></td>
Code Behind userControl.ascx
public bool Editable
{
get
{
if (ViewState["editable"] != null)
{
return (bool)ViewState["editable"];
}
else
{
return true;
}
}
set
{
ViewState["editable"] = value;
}
}
protected override void OnPreRender(EventArgs e)
{
//Find o botao edit visible
Button EditButton=
FormView1 .FindControl ("EditButton") as Button;
if (EditButton !=null )
{
EditButton .Visible =Editable ;
}
}
Dropdownlist' has a Selectedvalue which is invalid because it does not exist in the list of items. Parameter name: value
Exception Details: System.Argued tofrangeexception: 'Deliver dropdownlist' has a Selectedvalue which is invalid because it does not exist in the list of items. Parameter name: value
Source Error:
Line 30: {
Line 31: //Find the Visible Edit button
Line 32: Button Editbutton=
Line 33: Formview1 . Findcontrol ("Editbutton") as Button;
Line 34: if (Editbutton != null )
Source File: c: Users PC Documents Visual Studio
2012 Baumsgvo Websites Usercontrols Clientesdetalhes.ascx.Cs Line: 32
Stack Trace:
[Tofrangeexception argued: 'Deliver Dropdownlist' has a Selectedvalue which is invalid because it does not exist in the list of items. Parameter name: value]
Thank you !!!!! I managed to solve the error
– joany
I gave one
bind
before trying to catch theselectedvalue
and it worked. Thank you.– user43630