I had my design like this which is in a user control as
<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>
and my C# Code is
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;
}
}
and my paging itemcommand event is
protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("Paging"))
{
CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
BindDataItems();
}
}
But i dont know why the hell the item command event is not raising? Could anyone help me out in this?
Perhaps you are not assigning the actual
DataSourcetoDataList, use this piece of code instead: