asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Code Samples
Components
Tools
New
Free
Downloads
Vendors
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Populating a Selectbox

This script populates a selectbox with values from a database table and selects the correct item for the current record.


<SELECT NAME="cboSomefield">
<%
   Dim objConn, objRS, objRS2
   Set objConn = Server.CreateObject("ADODB.Connection")
   objConn.Open "DSN=SomeDSN;"
   Set objRS = objConn.Execute("SELECT CategoryID FROM SomeTable WHERE
SomeField = " & Request.QueryString("id"))
   If Not objRS.EOF Then
     objRS2 = objConn.Execute("SELECT CategoryID FROM SomeOtherTable")
     While Not objRS2.EOF
%>
     <OPTION VALUE="<%=objRS2("CategoryID")%>"<%If objRS2("CategoryID") =
 objRS("CategoryID") Then Response.Write "
SELECTED"%>><%=objRS2("CategoryID")%>
<%
       objRS.MoveNext
     Wend
     objRS2.Close
     Set objRS = Nothing
   End If
%>
</SELECT>

Submitted by Peter McMahon



email this code sample to a colleague




Support the Active Server Industry

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs