Classic ASP Select (Combo Box)
I have a record set with fieldNames and fieldIDs and I would like to populate a Select (comboBox/DropDownList) and I'm not sure how to do it (I normally use ASP.Net).
I just simple want the user to be able to see the fieldName (IE: rsRecordSet.FieldName) when they click on the comboBox, but I dont know the syntax to do this. So far I have the following code:
While not rsRecordSet.EOF
If rsRecordSet.State = adStateOpen Then rsRecordSet.Close
Set rsRecordSet= nothing
Not sure I understand, and maybe you can clarify. You want the field name, but you are referencing the element by field name? Why not just have the text in the field, like this:
Or were you trying for something like this:
Where columno is the number of the column you want to get the fieldname for.
thanks for your post. Actually, I fieldName is the name of the column, I am referencing by that and I want the user to see the values in that column when they click on the comboBox but it is not populating.
Okay. I think I understand what you require.
In terms of functionality and features ASP.Net is quite differnet then ASP.
Hope this helps..
thanks for your post, but this I dont think that's the issue: the problem is that when the user first sees the page there should be data bound to the combo box from the recordset and this is not happening.
When the user clicks on the combo box all he sees is blank space, nothing, no values, i need to bind the columns in the recordset to the combobox and i need to know if my syntax that i first posted is incorrect. thanks.
Do you mean the user cannot see the options within the combo box?
Originally Posted by MyronCope
this way the data is bound to the Option value and also displayed for the user.
"To steal ideas from one person is plagiarism; to steal from many is research."
If I understand what you want then you want the user to see Column names and not the actual data stored in the table. If so then try this code.
For iLoop = 0 to rsRecordSet.Fields.Count - 1
<option value="<% Response.Write rsRecordSet.Fields(iLoop).Name %>"><% Response.Write rsRecordSet.Fields(iLoop).Name %></option>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)