I am facing problem with DataPager control. I had set PagedControlID to a ListView control, PageSize=5 and added <asp:NumericPagerField /> under fields section.ListView Control is bound to Xml file.
Problem is when there are 10 records, '1' and '2' link controls are displayed in the pager control but when I click on '2' i.e. on second page nothing happens. I tried to debug it, every time I click on page links page_load is getting fired. But when i click
on '2' for the first click "StartRowIndex" remains 0 and on second click it turns 5. Below is my code:
Thanks,
Sundeep Podugu
My Blog --------------------------------------------------
If there is any mistake/suggestion in any of my conversation in this forum, please let me know.
sundeep_38
Contributor
3541 Points
604 Posts
Problem with Data Pager
Jan 13, 2009 01:56 AM|LINK
Hi,
I am facing problem with DataPager control. I had set PagedControlID to a ListView control, PageSize=5 and added <asp:NumericPagerField /> under fields section.ListView Control is bound to Xml file.
Problem is when there are 10 records, '1' and '2' link controls are displayed in the pager control but when I click on '2' i.e. on second page nothing happens. I tried to debug it, every time I click on page links page_load is getting fired. But when i click on '2' for the first click "StartRowIndex" remains 0 and on second click it turns 5. Below is my code:
<asp:ListView ID="lvComments" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<%#Eval("date") %><br />
<p><%#Eval("text") %></p>
</ItemTemplate>
<ItemSeparatorTemplate>
<hr />
</ItemSeparatorTemplate>
</asp:ListView>
<asp:DataPager ID="dpComments" runat="server" PagedControlID="lvComments" PageSize="5">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
Code-Behind:
If(!IsPostBack)
{
XElement xmlCommentsData = XElement.Load(commentsFilePath);
var xmlComments = (from c in xmlCommentsData.Elements("comment")
select c);
List<Comment> objCommentsList = new List<Comment>();
foreach (var comment in xmlComments)
{
Comment objComment = new Comment();
objComment.id = int.Parse(comment.Element("id").Value);
objComment.text = comment.Element("text").Value;
objComment.date = (Convert.ToDateTime(comment.Element("date").Value)).ToLongDateString();
objCommentsList.Add(objComment);
}
lvComments.DataSource = objCommentsList;
lvComments.DataBind();
}
Please help me with this.
Sundeep Podugu
My Blog
--------------------------------------------------
If there is any mistake/suggestion in any of my conversation in this forum, please let me know.