0

私はリピーターを使用していましたが、 ....htmlcaption1のように増やしたいです:htmlcaption2htmlcaption3

 <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か?

答えてくれてありがとう

4

1 に答える 1

3

これを試すことができると思います:

<ItemTemplate>
         <img src="<%#DataBinder.Eval(Container.DataItem,"BannerPath")%>" alt="<%# "#htmlcaption" + (Container.ItemIndex + 1).ToString() %>"  />
</ItemTemplate>

ただし、その場合にaltを指定することはあまり役に立ちません...または、少なくとも画像を説明していないため、別のものではありません。

于 2013-05-24T11:06:29.553 に答える