|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
[ASP] raccogliere tre valori con una ListBox()
con ASP.NET:
per raccogliere 2 valori quali l'ID e il testo, con una ListBox() ho usato la classe "MyListItem" Codice:
Public Class MyListItem
Private m_id As Long
Private m_text As String
Public Overrides Function ToString() As String
Return m_text
End Function
Public Sub New(ByVal Text As String, ByVal Value As Long)
m_text = Text
m_id = Value
End Sub
Public Property Value() As Long
Get
Return m_id
End Get
Set(ByVal Value As Long)
m_id = Value
End Set
End Property
Public Property Text() As String
Get
Return m_text
End Get
Set(ByVal Value As String)
m_text = Value
End Set
End Property
End Class
Codice:
'popolo la ListBox Categorie
conn.Open()
Dim sql As String = "SELECT * FROM Categorie"
Dim comm As New OleDbCommand(sql, conn)
Dim read As OleDbDataReader = comm.ExecuteReader
While read.Read()
lsbCat.Items.Add(New ListItem(read("Cat"), read("Id").ToString))
End While
conn.Close()
Codice:
Dim Item As MyListItem = lsbCat.SelectedItem
Dim ID As Integer = Item.Value
Dim Categoria As String = Item.Text
i tre campi da gestire ID = integer Cat = string IDC = integer la mia tabella: ID -- Cat -- IDC |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Feb 2001
Città: Nordest
Messaggi: 217
|
Basta aggiungere alla classe:
Codice:
Private m_idc As Integer
...
Public Property IDC() As Integer
Get
Return m_idc
End Get
Set(ByVal Value As Integer)
m_idc = Value
End Set
End Property
|
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
Ma mi da errore:
Codice:
lsbSubCat.Items.Add(New MyClass1(read("SubCat"), read("Id").ToString, read("IDC").ToString)) tipo: ByVal value2 As Integer..........??? Public Sub New(ByVal Text As String, ByVal Value As Long, ByVal value2 As Integer) altrimenti mi dice di passargli solo 2 parametri..... ma come ho fatto io non funziona!!!!!! In ALLEGATO.. c'e' l'errore.....!!!!!! la classe : Public Class MyClass1 Private m_idc As Long Private m_id As Long Private m_text As String Public Overrides Function ToString() As String Return m_text End Function Public Sub New(ByVal Text As String, ByVal Value As Long, ByVal IDC As Long) m_text = Text m_id = Value m_idc = IDC End Sub Public Property Value() As Long Get Return m_id End Get Set(ByVal Value As Long) m_id = Value End Set End Property Public Property Text() As String Get Return m_text End Get Set(ByVal Value As String) m_text = Value End Set End Property Public Property IDC() As Long Get Return m_idc End Get Set(ByVal Value As Long) m_idc = Value End Set End Property End Class |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Feb 2001
Città: Nordest
Messaggi: 217
|
Il problema è tutto qui:
Codice:
lsbSubCat.Items.Add(New MyClass1(read("SubCat"), read("Id").ToString, read("IDC").ToString)) Ecco la soluzione: Codice:
lsbSubCat.Items.Add(New MyClass1(read("SubCat"), read("Id"), read("IDC"))) |
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
OK provo e poi ti faccio sapere, grazie mille per ora, ciao!!
|
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
Mi da errore!!!!!!!!!
guarda l'allegato......... ---> |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 14:41.



















