P
phlian
I've got a dropdownlist (webform) bound to an arraylist which holds my
several of a custom object as follows:
fldOption.DataSource = prod.Items
fldOption.DataTextField = "Options"
fldOption.DataValueField = "ID"
fldOption.DataBind()
(prod.Items is an arraylist containing objects of type cItem)
Seems straight forward enough, and the control works fine.
The problem comes when I try to get a reference to the cItem that is
selected. One would think that:
dim i as cItem = CType(fldOption.SelectedItem, cItem)
would do the trick...but it doesn't. Instead I get:
Value of type 'System.Web.UI.WebControls.ListItem' cannot be converted
to 'cItem'.
Yes, I could simply loop through the prod.Items arraylist and look for
matching IDs...in fact I'll probably go code it that way now, since I
need to get this done. But that seems to be a less than elegant
solution to the problem.
Am I misunderstanding something here? Any help appreciated.
several of a custom object as follows:
fldOption.DataSource = prod.Items
fldOption.DataTextField = "Options"
fldOption.DataValueField = "ID"
fldOption.DataBind()
(prod.Items is an arraylist containing objects of type cItem)
Seems straight forward enough, and the control works fine.
The problem comes when I try to get a reference to the cItem that is
selected. One would think that:
dim i as cItem = CType(fldOption.SelectedItem, cItem)
would do the trick...but it doesn't. Instead I get:
Value of type 'System.Web.UI.WebControls.ListItem' cannot be converted
to 'cItem'.
Yes, I could simply loop through the prod.Items arraylist and look for
matching IDs...in fact I'll probably go code it that way now, since I
need to get this done. But that seems to be a less than elegant
solution to the problem.
Am I misunderstanding something here? Any help appreciated.