R
Rob Meade
Hi all,
With some help from Jakob Christensen here, and also this article (for
VB'ing it)..
http://www.componentdesigns.com/library/article.asp?a=2
I 'think' I have managed to achieve what I want to do (which was to write
both Text and a Value to each row in the combo box).
My next problem is that I seem to be unable to then 'get' the value of the
selected item in the combo box...
Any help would be appreciated, the following code is being used :
Public Class ComboBoxElement
Dim m_ElementText As String
Dim m_ElementValue As Integer
Public Sub New(ByVal ElementText As String, ByVal ElementValue As
Integer)
m_ElementText = ElementText
m_ElementValue = ElementValue
End Sub
Public ReadOnly Property ElementText() As String
Get
Return m_ElementText
End Get
End Property
Public ReadOnly Property ElementValue() As String
Get
Return m_ElementValue
End Get
End Property
Public Overrides Function ToString() As String
Return ElementText
End Function
End Class
And I'm setting the values with this in my page_load :
ComboBox1.Items.Add(New ComboBoxElement("Please select a payment option...",
99))
ComboBox1.Items.Add(New ComboBoxElement("Weekly Paid (£14.95 admin cost for
each week of use)", 1))
ComboBox1.Items.Add(New ComboBoxElement("Monthly Paid (£44.95 admin cost for
each month of use)", 2))
I have managed to return the 'index' value for the selected item in the
combo box, but then I dont seem to be able to find a way to use this to
retrieve the text or the value from it (the value is what I am really
after)..
Your help is appreciated,
Regards
Rob
With some help from Jakob Christensen here, and also this article (for
VB'ing it)..
http://www.componentdesigns.com/library/article.asp?a=2
I 'think' I have managed to achieve what I want to do (which was to write
both Text and a Value to each row in the combo box).
My next problem is that I seem to be unable to then 'get' the value of the
selected item in the combo box...
Any help would be appreciated, the following code is being used :
Public Class ComboBoxElement
Dim m_ElementText As String
Dim m_ElementValue As Integer
Public Sub New(ByVal ElementText As String, ByVal ElementValue As
Integer)
m_ElementText = ElementText
m_ElementValue = ElementValue
End Sub
Public ReadOnly Property ElementText() As String
Get
Return m_ElementText
End Get
End Property
Public ReadOnly Property ElementValue() As String
Get
Return m_ElementValue
End Get
End Property
Public Overrides Function ToString() As String
Return ElementText
End Function
End Class
And I'm setting the values with this in my page_load :
ComboBox1.Items.Add(New ComboBoxElement("Please select a payment option...",
99))
ComboBox1.Items.Add(New ComboBoxElement("Weekly Paid (£14.95 admin cost for
each week of use)", 1))
ComboBox1.Items.Add(New ComboBoxElement("Monthly Paid (£44.95 admin cost for
each month of use)", 2))
I have managed to return the 'index' value for the selected item in the
combo box, but then I dont seem to be able to find a way to use this to
retrieve the text or the value from it (the value is what I am really
after)..
Your help is appreciated,
Regards
Rob