我想在中继器控件中的每三个项目之后放置一个休息时间。我怎样才能做到这一点 ?

<asp:Repeater ID="rptrExample" runat="server">
   <ItemTemplate>
      <td width="550px">
         <p>E <%# DataBinder.Eval(Container, "DataItem.price") %></p>
             <img alt='<%# DataBinder.Eval(Container, "DataItem.title") %>' src='<%# DataBinder.Eval(Container, "DataItem.url") %>'                                      width="184px" height="140px" style="border-color: #0d6e74; border: 1px" />
      </td>
   </ItemTemplate>
</asp:Repeater>


代码背后:

public void LoadJewels()
{
    OdbcConnection conn;
    string requestbron = Request.QueryString["bron"];
    requestbron = requestbron != null ? requestbron : "1";
    conn = new OdbcConnection(ConfigurationManager.ConnectionStrings["jewelsConnectionString"].ConnectionString);
    conn.Open();
    string sql = "SELECT price, url FROM item AS a LEFT JOIN picture AS b ON a.iid = b.iid WHERE cid =" + Convert.ToInt32(requestbron) + " AND bigpicture =1";

    OdbcCommand cmd = new OdbcCommand(sql, conn);

    try
    {
        rptrExample.DataSource = cmd.ExecuteReader();
        rptrExample.DataBind();

        cmd.Connection.Close();
        cmd.Connection.Dispose();
    }
    catch (Exception ex)
    {
        lblStatus.Text = ex.Message;
    }
}

最佳答案

<br runat="server" Visible="<%# (Container.ItemIndex % 3) == 2 %>" />

关于c# - 中断中继器控制,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3125096/

10-10 19:16