hi
I used pagination for datalist below is code:
<asp:Repeater ID="rptPager2" runat="server" Visible="false">
<ItemTemplate>
<asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>'
CssClass='<%# Eval("CssClass") %>' OnClick="Page_ChangedPL" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
And code:
protected void Page_ChangedPL(object sender, EventArgs e)
{
int pageIndex = int.Parse((sender as LinkButton).CommandArgument);
//this.GetCustomersPageWiseMC(pageIndex, ViewState["LinkButtonValue"].ToString());
if (ViewState["LinkButtonValue"] == null)
{
this.GetCustomersPageWise(pageIndex);
BindDataList(DLclass, "class_documentry");
}
else
{
this.GetCustomersPageWiseMC(pageIndex, ViewState["LinkButtonValue"].ToString());
DataListItem item = (DataListItem)(sender as LinkButton).NamingContainer;
foreach (DataListItem dlItems in DLclassC.Items)
{
LinkButton lb = dlItems.FindControl("Linkbtnclass") as LinkButton;
lb.ForeColor = ColorTranslator.FromHtml("#646464");
}
(item.FindControl("Linkbtnclass") as LinkButton).ForeColor = ColorTranslator.FromHtml("#fb00c2");
BindDataListT(DLclassC, "classTI_documentry");
}
}
when I click on page number to change datalist this error happen:
Unable to cast object of type 'System.Web.UI.WebControls.RepeaterItem' to type 'System.Web.UI.WebControls.DataListItem'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.RepeaterItem' to type 'System.Web.UI.WebControls.DataListItem'.
Source Error:
Line 294:
Line 295: this.GetCustomersPageWiseMC(pageIndex, ViewState["LinkButtonValue"].ToString());
Line 296: DataListItem item = (DataListItem)(sender as LinkButton).NamingContainer;
Line 297: foreach (DataListItem dlItems in DLclassC.Items)
Line 298: {
|
what should I do?
Best Regards
Neda