Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting the ListIndex of Combo at run time(URGENT)
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00469368
Message ID:
00469385
Vues:
14
>Hi,
>
> I am using ASP and SQL Server 7.0 as a backend
>On my page i am usning 2 combos and i wan to set the listindex of those combos at run time
>
> How should i do that ? ? ?
>
>
> Pls tell me with an example . . .
>
>
>
>
>Thanx in advance,
>Amol

If I understand your question correctly, then the trick is to check the index value as you loop through your recordset and then write out the "selected" keyword into the option tag when you hit it. Something like this:
<%
' intSelectedIndex is the index where you want the combo to be selected.
' This could be a variable you set elsewhere in script
intSelectedIndex = 3

' Assume a recordset oRS with a column called "index" for the index and 
' a column called "desc" for the description
Do While Not oRS.EOF%
     <option 
          <%If oRS("index") = intSelectedIndex Then Response.Write "selected " End If% 
          value=<%=oRS("index")%<%=oRS("desc")<%
     oRS.MoveNext
Loop
%
"It is an important and popular fact that things are not always what they seem. For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much -- the wheel, New York, wars and so on -- whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man -- for precisely the same reasons." - Douglas Adams
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform