asp.net – 如何在转发器中使用不同的样式?
发布时间:2020-12-16 03:28:10 所属栏目:asp.Net 来源:网络整理
导读:对于第一项我想使用以下 div: div class="six columns" a href="" img src="" / h3Israeli Embassy Promotes Peace/h3 h4At a time when Israel is facing threats of.../h4 /a/div 这是休息我想使用以下 div: div class="six columns" ul lia href="" h3T
对于第一项我想使用以下< div>:
<div class="six columns"> <a href=""> <img src="" /> <h3>Israeli Embassy Promotes Peace</h3> <h4>At a time when Israel is facing threats of...</h4> </a> </div> 这是休息我想使用以下< div>: <div class="six columns"> <ul> <li><a href=""> <h3>This is the first alskdjlak s</h3> </a></li> <li><a href=""> <h3>asd sad asd asd asdasdasdas d</h3> </a></li> <li><a href=""> <h3>dsad asd asd asd asd asd asd</h3> </a></li> </ul> </div> 我该怎么做? 解决方法
首先在后面的代码上使用一个整数,即从1开始.
然后在转发器上检查这个值,你会像: <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <% if (iCounter == 1) { %> <br />First line id: <%# GetID(Container.DataItem) %> <% } else { %> <br />Next lines id: <%# GetID(Container.DataItem) %> <% } iCounter++; %> </ItemTemplate> </asp:Repeater> 并在代码背后: public int iCounter = 1; List<int> oMainIds = new List<int>(); protected void Page_Load(object sender,EventArgs e) { for (int i = 0; i < 10; i++) { oMainIds.Add(i); } Repeater1.DataSource = oMainIds; Repeater1.DataBind(); } public int GetID(object oItem) { return (int)oItem; } 请注意,对于测试,这里我放置了10条数据线.此示例呈现: First line id: 0 Next lines id: 1 Next lines id: 2 Next lines id: 3 Next lines id: 4 Next lines id: 5 Next lines id: 6 Next lines id: 7 Next lines id: 8 Next lines id: 9 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-4 – ASP.NET MVC 4捆绑无法正常工作
- asp.net-mvc – ASP.NET MVC使用相同的控制器分离移动视图
- ASP.NET Web Service中XML文档中的非法字符
- asp.net-mvc – 将模型传递给RedirectToAction()
- asp.net-web-api2 – 通过http Post请求将XML发送到Web Api
- asp.net-mvc – ASP.NET MVC是否容易受到oracle的填充攻击?
- asp.net – DbFunctions.TruncateTime在ASP .NET CORE中的L
- asp.net-mvc – ViewModel中的MVC3 RouteUrl
- ASP.NET MVC从请求参数中删除双正斜杠
- asp.net-mvc – ASP.NET MVC,强类型视图,部分视图参数毛刺
推荐文章
站长推荐
- asp.net-mvc – 如何处理从ASP MVC版本4.0.0.0到
- asp.net – 在不使用MVC的情况下在WebPages中渲染
- asp.net – 仅允许匿名用户通过web.config授权
- asp.net – HttpClient不会从CookieContainer发送
- asp.net-mvc – 如何在MVC中显示图像
- asp.net – viewStateEncryptionMode =“始终”不
- asp.net – Thread.CurrentPrincipal在使用WebGe
- 当我尝试调试ASP.NET程序时,为什么Internet Expl
- asp.net – ASP .net当前物理位置
- asp.net-mvc – 如何在回发后保持dropdownlist选
热点阅读