我在代码隐藏页面中有一个公共列表,它已成功绑定。我想访问它并在设计页面中显示数据,数据可以从列表中访问,但它没有显示页面上列表项的值。
private void GetAnnouncements()
{
var List = (from a in db.ANNOUNCEMENTS
orderby a.CREATEDON descending
select a).Take(3).ToList();
}
设计页面如下
<% if (List.Count > 0)
{
foreach (var item in List)
{%>
<div class="row">
<div class="col-md-12 faq-wrapper">
<div class="panel-group" id="accordion2">
<h3>ANNOUNCEMENTS</h3>
<div class="panel panel-default">
<div class="panel-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse11"> <% Convert.ToString(item.HEADING.ToString());%>
</a>
</div>
<div id="collapse11" class="accordion-body collapse">
<div class="accordion-inner">
<div class="answer"><% item.CREATEDON.ToString(); %> here</div>
<p>
<% item.ANNOUNCEMENT1.ToString(); %>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<%}
} %>