A
Aussie Rules
Hi,
I am migrating my skills from winforms to webforms, so sorry for the most
basic of questions
When I add an item into a dropdownlist in winforms, i create an object and
add the object to the dropdownlist using code such as
Dim oObject As New clsObject
oObject.ID = pRow("Style_ID")
oObject.Name = pRow("style_description".ToString)
cboStyle.Items.Add(oObject)
THis code does seem to work in webforms, as its pretty well much exactly
what I have used to populate the dropdownlist, however when I try to get
back the selected items ID using the code below, it fails with the error
'Unable to cast object of type 'System.Web.UI.WebControls.ListItem' to type
'clsObject'.'
The following code is from the dropdownlists selectedindexchanged event.
Dim oObject As clsObject
oObject = DirectCast(sender.SelectedItem, clsObject) ' fails on this line'
intGenre = oObject.ID
Is there meant to be a different way to get back the selected object ?
Thanks
I am migrating my skills from winforms to webforms, so sorry for the most
basic of questions
When I add an item into a dropdownlist in winforms, i create an object and
add the object to the dropdownlist using code such as
Dim oObject As New clsObject
oObject.ID = pRow("Style_ID")
oObject.Name = pRow("style_description".ToString)
cboStyle.Items.Add(oObject)
THis code does seem to work in webforms, as its pretty well much exactly
what I have used to populate the dropdownlist, however when I try to get
back the selected items ID using the code below, it fails with the error
'Unable to cast object of type 'System.Web.UI.WebControls.ListItem' to type
'clsObject'.'
The following code is from the dropdownlists selectedindexchanged event.
Dim oObject As clsObject
oObject = DirectCast(sender.SelectedItem, clsObject) ' fails on this line'
intGenre = oObject.ID
Is there meant to be a different way to get back the selected object ?
Thanks