我有一個ASCX文件中的下列中繼器:中繼器不顯示第二組數據綁定後什麼
<asp:Repeater ID="repeater1" runat="server">
<HeaderTemplate>
<ul class="formList">
</HeaderTemplate>
<ItemTemplate>
<li><a href="plugins/umbracocontour/editForm.aspx?guid=<%# ((Umbraco.Forms.Core.Form)Container.DataItem).Id %>"
class="form">
<%# ((Umbraco.Forms.Core.Form)Container.DataItem).Name %></a> <small><a href="plugins/umbracocontour/editForm.aspx?guid=<%# ((Umbraco.Forms.Core.Form)Container.DataItem).Id %>">
Open form designer</a> <a href="plugins/umbracocontour/editFormEntries.aspx?guid=<%# ((Umbraco.Forms.Core.Form)Container.DataItem).Id %>">
View entries</a> </small></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
它通過一個名爲ShowAllForms()
private void ShowAllForms()
{
using (var formStorage = new FormStorage())
{
var list = formStorage.GetAllForms(false).OrderBy(f => f.Name).Where(form => Security.HasAccessToForm(form.Id)).ToList();
this.repeater1.DataSource = list;
this.repeater1.DataBind();
if (list.Count == 0)
{
this.paneBrowse.Visible = false;
}
}
}
和`方法填充數據SearchForms:
private void SearchForms()
{
var forms =
this.formRepository.GetFormByFreeText(this.txtFormSearch.Text).Where(form => Security.HasAccessToForm(form.Id)).
ToList();
this.repeater1.DataSource = forms;
this.repeater1.DataBind();
}
ShowAllForms()
被稱爲Page_Load
,如果沒有回發,也沒有「Show All Forms」按鈕的點擊事件。在「搜索表單」按鈕的回發中調用SearchForms()
。
作爲非管理員用戶,當我查看錶單列表時,我最初看到了一大堆表單。然後,我通過它的名稱搜索表單,該表單不會返回任何項目。到現在爲止還挺好。然後,我點擊「顯示所有表格」按鈕,將執行ShowAllForms()
,這是所謂的顯示所有形式的第一位。
但是,當第二次調用時,ShowAllForms()
不會在中繼器中顯示任何表單數據。爲了澄清,我可以看到在forms
變量中有返回的項目,所以這個集合不是空的,但是這些項目都沒有出現在中繼器中。
我對這裏會發生什麼感到困惑。
編輯:
的頁面OnLoad事件:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.ShowAllForms();
}
}
的OnInit:
protected void Page_Init(object sender, EventArgs e)
{
this.formRepository = TinyIoC.TinyIoCContainer.Current.Resolve<IFormRepository>();
}
你能告訴更多的代碼嗎? PageLoad和OnInit的頁面? – 2013-02-13 17:36:22
我已經添加了這些事件的代碼。 – 2013-02-13 17:45:08