Home All Groups Group Topic Archive Search About
Author
12 Oct 2006 10:25 PM
TJHerman
I've got two dropdowns which are unbound and which I bind the values of when
I update or insert. My method works on all of my other pages, but for some
reason is not working on this page. When I try to update the record (it's in
a formview), I get an IE message saying "Object must implement IConvertible."

I have the following code in the formview_ItemUpdating event:
******************************
Dim strCompanyName As String =
CType(FormView1.Row.FindControl("dropdownlist1"), DropDownList).SelectedValue
        Dim strCN As DropDownList =
CType(FormView1.Row.FindControl("DropDownList2"), DropDownList)

        e.NewValues("CompanyName") = strCompanyName
        e.NewValues("ComponentNumber") = strCN
******************
Can anyone help me with this?

Author
12 Oct 2006 10:58 PM
Robert Haken [MVP]
> I have the following code in the formview_ItemUpdating event:
> ******************************
> Dim strCompanyName As String =
> CType(FormView1.Row.FindControl("dropdownlist1"),
> DropDownList).SelectedValue
>        Dim strCN As DropDownList =
> CType(FormView1.Row.FindControl("DropDownList2"), DropDownList)
>
>        e.NewValues("CompanyName") = strCompanyName
>        e.NewValues("ComponentNumber") = strCN
> ******************

What type is the ComponentNumber column? You cannot assign DropDownList
there, use its SelectedValue instead, like in the first case...

Robert Haken [MVP ASP/ASP.NET]
HAVIT, s.r.o., www.havit.cz
http://knowledge-base.havit.cz
Author
13 Oct 2006 12:11 AM
TJHerman
Thank you so much! What a stupid error!

Show quoteHide quote
"Robert Haken [MVP]" wrote:

> > I have the following code in the formview_ItemUpdating event:
> > ******************************
> > Dim strCompanyName As String =
> > CType(FormView1.Row.FindControl("dropdownlist1"),
> > DropDownList).SelectedValue
> >        Dim strCN As DropDownList =
> > CType(FormView1.Row.FindControl("DropDownList2"), DropDownList)
> >
> >        e.NewValues("CompanyName") = strCompanyName
> >        e.NewValues("ComponentNumber") = strCN
> > ******************
>
> What type is the ComponentNumber column? You cannot assign DropDownList
> there, use its SelectedValue instead, like in the first case...
>
> Robert Haken [MVP ASP/ASP.NET]
> HAVIT, s.r.o., www.havit.cz
> http://knowledge-base.havit.cz
>
>
>