我有这样的设计,它在用户控件中
<table>
<tr>
<td>
<asp:DataList ID="dlimgShowCase" runat="server" RepeatDirection="Horizontal" EnableViewState="true">
<ItemTemplate>
<asp:Image ID="imgCatalog" runat="server" Height="292" Width="454" ImageUrl='<%# Eval("path") %>' />
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="dlPaging" runat="server" class="more_pages_navigation" RepeatDirection="Horizontal"
Width="100" OnItemCommand="dlPaging_ItemCommand" OnItemDataBound="dlPaging_ItemDataBound"
EnableViewState="true">
<ItemTemplate>
<li>
<asp:LinkButton ID="lnkbtnPaging" runat="server" CommandArgument='<%# Eval("PageIndex") %>'
CommandName="Paging" Text='<%# Eval("PageText") %>' Style="text-align: center"
OnClick="lnkbtnPaging_Click"> </asp:LinkButton>
</li>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
我的 C# 代码是
if (!IsPostBack)
{
BindDataItems();
}
/// <summary>
/// Binding Images List
/// </summary>
private void BindDataItems()
{
// If the DataSource Tables are greater than 1
try
{
if (Cache["DataShowcaseImages"] == null)
Cache["DataShowcaseImages"] = DataSource.Tables[0];
objPagedDataSourceCatalogList.DataSource = ((DataTable)(Cache["DataShowcaseImages"])).DefaultView;
objPagedDataSourceCatalogList.AllowPaging = true;
objPagedDataSourceCatalogList.PageSize = PageSize;
objPagedDataSourceCatalogList.CurrentPageIndex = CurrentPage;
ViewState["TotalPages"] = objPagedDataSourceCatalogList.PageCount;
dlimgShowCase.DataSource = objPagedDataSourceCatalogList;
dlimgShowCase.DataBind();
performPaging(); // This method bind my second grid,, with page numbers
}
catch (Exception)
{
throw;
}
}
我的分页 itemcommand 事件是
protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("Paging"))
{
CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
BindDataItems();
}
}
但我不知道为什么项目命令事件没有引发?谁能帮我解决这个问题?