前台代码:
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="width: 350px; float: left;">
<asp:Literal ID="litVideo" runat="server"></asp:Literal><br />
<asp:Repeater runat="server" ID="rptVideoName" OnItemDataBound="rptVideoName_ItemDataBound" OnItemCommand="rptVideoName_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="lbVideoName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Title")%>' CommandName="PlayVideo" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"ID")%>'></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
</asp:UpdatePanel>
后台代码:
//绑定repeater的个数,每行3个
protected void rptCategories_ItemDataBound(object src, RepeaterItemEventArgs e)
{
// Add <tr> for change row
if ((e.Item.ItemIndex + 1) % 3 == 0)
{
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
}
//repeater相应单击事件
protected void rptVideoName_ItemCommand(object sender, RepeaterCommandEventArgs e)
{
if (e.CommandName == "PlayVideo")
{
BindVideoName();
SPQuery query = new SPQuery();
SPList list = SPContext.Current.Web.Lists[ListNames.CompanyPublicityVideo];
SPListItem item = (new SharePointService()).GetItem(list, int.Parse(e.CommandArgument.ToString()));
this.litVideo.Text = PlayVideo(item.Folder, "autoplay=''");
}
}