Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How do I fix this error. I am setting a datalist like this: data list screenshot here

And I have table like this:

+-------------------+
|---ID----|---NAME--|
+-------------------+
|---101---|---CNN---|
|---102---|---BBM---|
+-------------------+
On the datalist I am using ID for listfield. I want show the name directly in the textbox when i choose ID list from listfield.
e.g. : i choose ID 101 in datalist then show CNN in textboxname

Private Sub DataList1_Click()
    Txtnama.Text = DataList1.ListField = "nama"
End Sub

Problem: the textbox just shows "false". How do I fix this code. please help me
thanks

vb6

What I have tried:

Private Sub DataList1_Click()
    Txtnama.Text = DataList1.ListField = "nama"
End Sub
Posted
Updated 30-May-17 21:19pm
Comments
F-ES Sitecore 26-May-17 5:25am    
It's going to be something like

Txtnama.Text = DataList1.Text

or you might need to look around DataList1.SelectedItem, it might be a property on there. You're seeing "false" as your code is setting Txtnama.Text to be the result of
'DataList1.ListField = "nama"' - ie a comparison as as the comparison is false that is what is appearing in your text field.
Khabibb Mubarakk 26-May-17 12:37pm    
I want show different list field on text box .. If I click 101 from dtalist then showing CNN on textbox.. Please read carefully my detail. That I want....
So I don't use textnama.text=datalist1.text because I want showing different item.. Or u have suggestions how to show data on text box when choose list on datalist but different data..

1 solution

why it sould display something else.

DataList1.ListField = "nama"   '---> False
Txtnama.Text = False


also for the next Error ... the column name.... Name or nama? :)

why use VB6(1998) in 2017, thats near 20 years old now. just download VS2017 Comunity, its free
 
Share this answer
 
Comments
Khabibb Mubarakk 26-May-17 2:56am    
ON DATALIST i use ID ..when i choose id ex 101 then in textboxnama show CNN..
stuck here.. this some project from teacher

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900