IConvertible Error

T

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?
 
R

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
 
T

TJHerman

Thank you so much! What a stupid error!

Robert Haken said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,224
Latest member
Gwen068088

Latest Threads

Top