• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Asp.net嵌套

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

   asp.net实现了代码的后置,页面与后台代码分开,比起asp逻辑清晰的很多,不过我感觉有时候为了方便,必要的时候实现内嵌的方式还是很不错的,今天在做一个产品根据类型轮换显示的时候用到了内嵌,方便了很多

首先要根据类型的数量循环出几个表格出来,然后根据类型循环显示显示产品,使用内嵌一步到位,代码如下

 

View Code
 1   <%
 2                                  
 3         System.Data.DataSet dsType = ProTypeManager.GetList(8" pid=0"" id asc");
 4         for (int i = 0; i < dsType.Tables[0].Rows.Count; i++)
 5         {
 6             string BType = dsType.Tables[0].Rows[i]["id"].ToString();
 7             System.Data.DataSet ds = ProductManager.GetList(10" jh_btype=" + BType, "  jh_id desc");
 8             DataPro.DataSource = ds;
 9             DataPro.DataBind();
10            
11                                     %>
12                                     <%
13                                         if ((i + 1!= 1)
14                                         {
15              %>                      
16                                     
17                                     <table border="0" cellspacing="0" cellpadding="0" id="tgcpf<%=i+1 %>" style="display:none">
18                                    <%}
19                                         else { 
20                                         %>
21                                         <table border="0" cellspacing="0" cellpadding="0" id="tgcpf<%=i+1 %>" style="display:block">
22                                         <%
23                                         }
24                                              %>
25                                     <tr>
26                                       <td>
27                                           <asp:DataList ID="DataPro" runat="server" RepeatColumns="5">
28                                           <ItemTemplate>
29                                              <table border="0" cellspacing="0" cellpadding="0">
30                                                  <tr>
31                                                  <td width="118" height="93" align="center" valign="middle"><a href="#" target="_blank"><img src='userfiles/image/<%#Eval("jh_pic") %>' width="103" height="85" border="0" /></a></td>
32                                                  </tr>
33                                                  <tr>
34                                                  <td width="118" height="22" align="center" valign="middle"><a href="#" target="_blank">产品:<%#Eval("jh_name")%></a></td>
35                                                  </tr>
36                                              </table>
37                                           </ItemTemplate>
38                                           </asp:DataList>
39                                       </td>
40                                     </tr>
41                                    </table>                                    
42                                     <%
43                                    }
44                                     %>
45       

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
asp.netMVC验证注解发布时间:2022-07-10
下一篇:
如何将一个ASP.NETMVC4和WebAPI项目升级到ASP.NETMVC5和WebAPI2发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap