|
-
Sep 27th, 2005, 06:47 AM
#1
Thread Starter
Fanatic Member
listbox control
i want to have a list box with three rows,
i want these rows to be bound to a three fields of one table
i dont think my list is databound at all
what am i missing here
thanks
VB Code:
daincMsg3.SelectCommand = New SqlCommand("SELECT * from tb_comp_detail WHERE (c_companycode = '" & lblUser.Text & "')", oSQLConn)
daincMsg3.Fill(dsIncMsg3)
lstMessage.Items.Add(New ListItem("Default", "c_msg_default"))
lstMessage.Items.Add(New ListItem("Message1", "c_msg_custom1"))
lstMessage.Items.Add(New ListItem("Message2", "c_msg_custom2"))
lstMessage.DataBind()
oSQLConn.Close()
it works 60% of the time, all the time.
-
Sep 27th, 2005, 10:13 AM
#2
Re: listbox control
Well your adding items not binding them. What you want to do is use the DataSource, DataTextField and the DataValueField property. Like this;
Code:
lstMessage.DataSource = dsIncMsg3
lstMessage.DataTextField = "Column to display"
lstMessage.DataValueField = "Column value"
TPM
Add yourself to the VBForums Frappr Map!!
-
Sep 28th, 2005, 04:21 AM
#3
Thread Starter
Fanatic Member
Re: drop down now
DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Message2.
VB Code:
daincMsg3.SelectCommand = New SqlCommand("SELECT * from tb_comp_detail WHERE (c_companycode = '" & lblUser.Text & "')", oSQLConn)
daincMsg3.Fill(dsIncMsg3)
lstMessage.DataSource = dsIncMsg3
lstMessage.Items.Add(New ListItem("Default", "c_msg_default"))
lstMessage.DataTextField = "c_msg_default"
lstMessage.DataValueField = "Default"
lstMessage.Items.Add(New ListItem("Message1", "c_msg_custom1"))
lstMessage.DataTextField = "c_msg_custom1"
lstMessage.DataValueField = " Message1"
lstMessage.Items.Add(New ListItem("Message2", "c_msg_custom2"))
lstMessage.DataTextField = "c_msg_custom2"
lstMessage.DataValueField = " Message2"
lstMessage.DataBind()
oSQLConn.Close()
getting errors i want my drop down to display
default
message1
message2
where they equal the column name as above
it works 60% of the time, all the time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|