0
我有一個ASP.NET的Repeater標記問題。它只是 在頁面運行時不會生成html代碼。我想 用它來生成標籤的列表,幻燈片,這裏是 ASP代碼:中繼器asp.net標記不工作
<asp:Repeater id="foto" runat="server">
<ItemTemplate>
<img src='<%# (string)Container.DataItem %>'/>
</ItemTemplate>
</asp:Repeater>
這裏是後面的代碼:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
int num = Directory.GetFiles(@"C:\Users\Paolo\Desktop\Podisti\Slideshow\" + Request.QueryString["Cartella"]).Length;
List<string> elencoUrl = new List<string>();
for (int i = 1; i <= num; i++)
elencoUrl.Add(@"Slideshow\" + Request.QueryString["Cartella"] + "00" + i + "_jpg.jpg");
foto.DataSource = elencoUrl; //può essere ad esempio un Array o una List di stringhe
foto.DataBind();
}
}
編輯: 謝謝你的答案,即使它不是問題的解決方案:我創建的頁面 只是一個測試,點擊2個鏈接按鈕,將 重定向到具有不同查詢字符串的同一頁面,以便中繼器可以 創建不同的src屬性每次都是img標籤。回發是在這裏 只是爲了防止頁面的第一次加載(查詢字符串爲空)的錯誤, 我會改變它,當我將解決這個問題。
的主要問題是:該轉發器沒有做的工作,如果我在執行過程中檢查 頁面代碼:
<div style="width:500px;height:400px">
<div class="fotorama">
/*The repeater doesn't create the <img> tags*/
</div>
</div>