Populating a DropDown List

Results 1 to 2 of 2

Thread: Populating a DropDown List

  1. #1
    Join Date
    Dec 1969

    Default Populating a DropDown List

    Hi - I&#039;ve always populated a dropdownlist just by looping<BR> through the records like below. Now I have a dropdownlist that will contain a lot of directors names and this method is a little slow. I&#039;ve read about the GetRows method, but I&#039;m not really getting it. Wondering if someone give me an exmaple of this or another better method. Thanks.<BR> <BR> ***************<BR> CREATE PROCEDURE up_Directors_DropDown<BR> AS<BR> SELECT Name = DirLName + &#039;, &#039; + DirFName, IDDir FROM<BR> TDirectors WHERE<BR> DirLName Is Not Null AND DirFName Is Not Null ORDER BY Name GO<BR> ****************<BR> <BR> &#060;!--#Include File="dbase.connection.asp"--&#062;<BR> <BR> &#060;%<BR> SqlText = "up_Directors_DropDown"<BR> <BR> &#039;Create our recordset - this recordset will be used to<BR> loop through<BR> our returned records<BR> Set rs = con.Execute(SqlText, adOpenForwardOnly)<BR> <BR> %&#062;<BR> <BR> &#060;!--Populate our Directors Dropdown list--&#062;<BR> <BR> &#060;form method="POST" action="whichsearch.asp"<BR> Select a Director&#060;br/&#062;<BR> <BR> &#060;select name="IDDir" size="1"&#062;<BR> &#060;%<BR> While NOT rs.EOF<BR> %<BR> &#060;option value="&#060;%=rs("IDDir")%"&#060;%=rs("Name")%&#0 62; &#060;/option&#062;<BR> <BR> &#060;%<BR> rs.MoveNext<BR> Wend<BR> <BR> rs.Close<BR> Set rs = nothing<BR> <BR> con.Close<BR> Set con = nothing<BR> %&#062;<BR> <BR> ************************

  2. #2
    Join Date
    Dec 1969

    Default GetRows() won't speed this up?

    It will simply allow you to close your connection and recordset and then write out your list. Probably a good idea anyway but it won&#039;t speed up the page load.<BR><BR>If you run your query in Query Analyzer, I think you&#039;ll find that the ORDER BY statement is causing a full table scan. I&#039;d suggest not concatenating the two values into NAME during the query. Do that in your ASP code. Change the ORDER BY to your DirLName and DirFName. If the table has an index on these two columns, the query should speed up quite a bit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts