在转发器控制中放置一个中断

时间:2010-06-26 18:45:22

标签: c# repeater

我希望在我的转发器控件中的每三个项目之后休息一下。我怎么能这样做?

<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;
    }
}

1 个答案:

答案 0 :(得分:4)

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