当前位置:编程学习 > C#/ASP.NET >>

产品数量等于1,大于1,分别对应两个超链接!

totalput=1 超链接 到product.asp
totalput>1 超链接 到productshow.asp --------------------编程问答-------------------- 用JS可以不?
>>>>>>>>>>------------------------------------------------------------------------------------------<<<<<<<<<<
--------------------编程问答-------------------- <a href='<%# HrefTo(Eval("totalput"))' %>链接</a>
后台

public string HrefTo(string str)
{
  if(int.Parse(str) > 1)
    return productshow.asp;
  else
     return product.asp;
} --------------------编程问答-------------------- <a href="" id="aId" runat="server">链接</a>
后台CS:

Load事件:
aId.HRef = totalput.Equals(1) ? "product.asp" : productshow.asp ;
--------------------编程问答-------------------- 先接收参数判断后再选择连接地址 --------------------编程问答-------------------- 是三个超连接,说错了 --------------------编程问答-------------------- <a herf='<%# (int)Eval("Satus")==1?"A.aspx":( (int)Eval("Satus")>1?"B.aspx":"C.aspx")%>'>xxxx</a> --------------------编程问答-------------------- 判断一下就可以了,这个很简单啊
if(totalput==1)
{response.redrect(url)}
............ --------------------编程问答--------------------
引用 3 楼 saisky 的回复:
<a href="" id="aId" runat="server">链接 </a> 
后台CS: 

C# code
Load事件:
aId.HRef = totalput.Equals(1) ? "product.asp" : productshow.asp ;

mark --------------------编程问答-------------------- if()
{respone.redict("url")}
else
{

}
--------------------编程问答-------------------- '=================================================
'过程名:ShowProductTotal
'作  用:显示文章总数
'参  数:无
'=================================================
sub ShowProductTotal()
dim sqlTotal
dim rsTotal
sqlTotal="select Count(*)  from Product where Passed=True "
if BigClassName<>"" then
sqlTotal=sqlTotal & " and BigClassName='" & BigClassName & "' "
if SmallClassName<>"" then
sqlTotal=sqlTotal & " and SmallClassName='" & SmallClassName & "' "
end if
else
if SpecialName<>"" then
sqlTotal=sqlTotal & " and SpecialName='" & SpecialName & "' "
end if
end if
Set rsTotal= Server.CreateObject("ADODB.Recordset")
rsTotal.open sqlTotal,conn,1,1
if rsTotal.eof and rsTotal.bof then
totalPut=0
response.write "共有 0 个产品"
else  
totalPut=rsTotal(0)
if totalPut=1 then

return "ProductShow.asp?ID=" & rsProduct("ID") & ""
else
return "Product.asp?BigClassName=<%=rss("BigClassName")%>&Smallclassname=<%=rss("SmallClassName")%>"

end if
end if
rsTotal.close
set rsTotal=nothing
end sub
把超联接换成return后面的
<a href="Product.asp?BigClassName=<%=rss("BigClassName")%>&Smallclassname=<%=rss("SmallClassName")%>"><%=rss("SmallClassName")%></a>
--------------------编程问答--------------------
引用 6 楼 qqshenyunzcz 的回复:
<a herf=' <%# (int)Eval("Satus")==1?"A.aspx":( (int)Eval("Satus")>1?"B.aspx":"C.aspx")%>'>xxxx </a>
================================================= 
'过程名:ShowProductTotal 
'作  用:显示文章总数 
'参  数:无 
'================================================= 
sub ShowProductTotal() 
dim sqlTotal 
dim rsTotal 
sqlTotal="select Count(*)  from Product where Passed=True " 
if BigClassName <>"" then 
sqlTotal=sqlTotal & " and BigClassName='" & BigClassName & "' " 
if SmallClassName <>"" then 
sqlTotal=sqlTotal & " and SmallClassName='" & SmallClassName & "' " 
end if 
else 
if SpecialName <>"" then 
sqlTotal=sqlTotal & " and SpecialName='" & SpecialName & "' " 
end if 
end if 
Set rsTotal= Server.CreateObject("ADODB.Recordset") 
rsTotal.open sqlTotal,conn,1,1 
if rsTotal.eof and rsTotal.bof then 
totalPut=0 
response.write "共有 0 个产品" 
else  
totalPut=rsTotal(0) 
if totalPut=1 then 

return "ProductShow.asp?ID=" & rsProduct("ID") & "" 
else 
return "Product.asp?BigClassName= <%=rss("BigClassName")%>&Smallclassname= <%=rss("SmallClassName")%>" 

end if 
end if 
rsTotal.close 
set rsTotal=nothing 
end sub 
把超联接换成return后面的 
<a href="Product.asp?BigClassName= <%=rss("BigClassName")%>&Smallclassname= <%=rss("SmallClassName")%>"> <%=rss("SmallClassName")%> </a> 
如何换啊
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,