0

我使用了中继器,我想增加htmlcaption1htmlcaption2htmlcaption3....:

 <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 回答