
asp中,在select中实现循环出错
<selectsize='1'name='SalesExperienceID'class=droplist><%dowhilenotrstemp.EOFifrstemp....
<select size='1' name='SalesExperienceID' class=droplist>
<%
do while not rstemp.EOF
if rstemp.Fields("typeid")=rs1("SalesExperienceID") then
%>
<option value="<%=rstemp.Fields("typeid")%> " selected><%=rstemp.Fields("typename")%></option>
<%
else
%>
<option value="<%=rstemp.Fields("typeid")%>" ><%=rstemp.Fields("typename")%></option>
<%
end if
rstemp.MoveNext
loop
rstemp.Close
%>
</select>
运行到这边之后,下拉框中是空的没有选项。这个sql语句确定能在数据库中查找到对应数据,rs1("SalesExperienceID")也确定存在。求大神告知是什么问题,如何解决。万分感谢! 展开
<%
do while not rstemp.EOF
if rstemp.Fields("typeid")=rs1("SalesExperienceID") then
%>
<option value="<%=rstemp.Fields("typeid")%> " selected><%=rstemp.Fields("typename")%></option>
<%
else
%>
<option value="<%=rstemp.Fields("typeid")%>" ><%=rstemp.Fields("typename")%></option>
<%
end if
rstemp.MoveNext
loop
rstemp.Close
%>
</select>
运行到这边之后,下拉框中是空的没有选项。这个sql语句确定能在数据库中查找到对应数据,rs1("SalesExperienceID")也确定存在。求大神告知是什么问题,如何解决。万分感谢! 展开
展开全部
根据你代码中的
if
else
end if ,
如果说sql语句确定能查找到数据,那应该能显示在 <select>中。
除非出现asp代码错误,导致无法显示到<select>中
rs1("SalesExperienceID") 这个值是 int 型?
rstemp.Fields("typeid") 也是 int 型?
<%
currentSalesExperienceID = rs1("SalesExperienceID") '可以先把这个值先提出取来
do while not rstemp.EOF
if rstemp.Fields("typeid")=currentSalesExperienceID then
%>
if
else
end if ,
如果说sql语句确定能查找到数据,那应该能显示在 <select>中。
除非出现asp代码错误,导致无法显示到<select>中
rs1("SalesExperienceID") 这个值是 int 型?
rstemp.Fields("typeid") 也是 int 型?
<%
currentSalesExperienceID = rs1("SalesExperienceID") '可以先把这个值先提出取来
do while not rstemp.EOF
if rstemp.Fields("typeid")=currentSalesExperienceID then
%>
追问
rs1("SalesExperienceID"),rstemp.Fields("typeid")这两个值都是int型的,刚在数据库里查的。rs1("SalesExperienceID")这个值是0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询