Problem with Attributes in DropDownList

adis

New member
Joined
Dec 4, 2005
Messages
1
Programming Experience
Beginner
Well here is my problem. I currently have a DB in MySQL and am populating seminars in a dropdownlist on the webpage. I fetch the Seminar Date and the Seminar ID(which is the primary key) and am trying to assign the Seminar ID as an attribute to the Seminar Date in the dropdown. I tried everything and it is not working. Here is the code below on how I am fetching the data. The code below displays the items in the dropdown as SeminarDate, (Seminar ID). What I am trying to do is hide that ID and the only way to get rid of it is assign it as an attribute or color it so it is not visible besides this i do not know of any other way. Thanks for any help.


If IsPostBack Then

Dim strSQL3 As String = "SELECT seminar_date,seminar_id FROM fb_seminar_tb WHERE fishbowl_id='" & substr & "'"
Dim sqlCmd2 As Odbc.OdbcCommand = New Odbc.OdbcCommand(strSQL3, dbConn)
Dim sqlDA2 As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter(sqlCmd2)
Dim sqlDT2 As DataTable = New DataTable("Drop Down 2 DT")

sqlDA2.Fill(sqlDT2)

Dim drow2 As DataRow

dropDown2.Items.Clear()
For Each drow2 In sqlDT2.Rows
dropDown2.Items.Add(drow2.Item("seminar_date") & " (" & drow2.Item("seminar_id") & ")")
Next
End If
 
you cannot add it that way!!!

you should use this for populating:
dropDown2.Items.Add(new listitem(drow2.Item("seminar_date"), drow2.Item("seminar_id"))

so if you don't want to show ID as value use date as value like:
dropDown2.Items.Add(new listitem(drow2.Item("seminar_date"), drow2.Item("seminar_date"))

attributes are added using Attributes.Add method.
 
Back
Top