我使用了转发器,我希望像htmlcaption1
,htmlcaption2
那样增加htmlcaption3
....:
<asp:Repeater ID="RepeaterBigBanner" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<img src="<%#DataBinder.Eval(Container.DataItem,"BannerPath")%>"alt="#htmlcaption1"" />
</ItemTemplate>
<SeparatorTemplate>
</SeparatorTemplate>
</asp:Repeater>
cs方:
sqlConn.Open();
sqlComm = sqlConn.CreateCommand();
sqlComm.Connection = sqlConn;
sqlComm.CommandText = "select Top(11) * from BannerYonetim where GosterimYeri='W' and Aktif=0 and BaslangicTarihi<getdate() and BitisTarihi>getdate() order by BaslangicTarihi";
sqlComm.CommandType = CommandType.Text;
SqlDataAdapter mySqlAdapter = new SqlDataAdapter(sqlComm);
DataSet myDataSet = new DataSet();
mySqlAdapter.Fill(myDataSet);
RepeaterBigBanner.DataSource = myDataSet;
RepeaterBigBanner.DataBind();
如何增加alt="#htmlcaption1"
:#htmlcaption2
,#htmlcaption3
... #htmlcaption11
?
谢谢你的回答
答案 0 :(得分:3)
我想你可以试试这个:
<ItemTemplate>
<img src="<%#DataBinder.Eval(Container.DataItem,"BannerPath")%>" alt="<%# "#htmlcaption" + (Container.ItemIndex + 1).ToString() %>" />
</ItemTemplate>
我觉得在这种情况下指定一个alt非常有用...但至少不是另一个,因为它没有描述图像。