Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
in my table i have 15 records based on assignment bca.. but in code behind if i am giving page size as 2 or more.. my code is not able to display any questions.
but if i give 25 as page size.. all questions are coming in the same page..i want paging for this...
Please help to me solve this..
 

 
My Code
public int PageNumber
{
get
{
if (ViewState["PageNumber"] != null)
return Convert.ToInt32(ViewState["PageNumber"]);
else
return 0;
}
set
{
ViewState["PageNumber"] = value;
}
}
 
int Qid;
protected void Page_Load(object sender, EventArgs e)
{
 

if (!IsPostBack)
{
 
if (Request.QueryString["id"] != null)
{
 
fillquestion();
 

 
}
}
}
 
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
rptPages.ItemCommand +=
new RepeaterCommandEventHandler(rptPages_ItemCommand);
}
 

 
public void fillquestion()
{
jaya j = new jaya();
 
int id = Convert.ToInt32(Request.QueryString["id"]);
// int id11 = Convert.ToInt32(Session["id"]);

 

 

DataTable dt = j.fillquestionuser(id);
 
PagedDataSource pgitems = new PagedDataSource();
DataView dv = new DataView(dt);
pgitems.DataSource = dv;
 
pgitems.AllowPaging = true;
pgitems.PageSize = 25;
pgitems.CurrentPageIndex = PageNumber;
 
if (pgitems.PageCount > 1)
{
rptPages.Visible = true;
ArrayList pages = new ArrayList();
for (int i = 0; i < pgitems.PageCount; i++)
pages.Add((i + 1).ToString());
rptPages.DataSource = pages;
rptPages.DataBind();
 
}
 

//if (dt.Rows.Count == 0)
//{

// DataList1.Visible = false;

//}

else
{
rptPages.Visible = false;
//DataList1.Visible = true;
DataList1.DataSource = pgitems;
DataList1.DataBind();
}
 

}
 
protected void rptPages_ItemCommand(object source, RepeaterCommandEventArgs e)
{
PageNumber = Convert.ToInt32(e.CommandArgument) - 1;
fillquestion();
}
 
My Design
<div class="que-panel">
 
<asp:Repeater ID="rptPages" Runat="server" onitemcommand="rptPages_ItemCommand" >
<HeaderTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><b>Page:</b> </td>
<td>
</HeaderTemplate>
 
<ItemTemplate>
<asp:LinkButton ID="btnPage"
CommandName="Page"
CommandArgument="<%#
Container.DataItem %>"
Runat="server"><%# Container.DataItem %>
</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
 

 
<asp:Repeater ID="DataList1" runat="server"
>
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server" ScrollBars="None">
<p><b><asp:Literal ID="Literal1" runat="server" Text='<%# Eval("question") %>'></asp:Literal></b></p>
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" cols="16" rows="8" class="answer" ></asp:TextBox>
</asp:Panel>
 
</ItemTemplate>
 

</asp:Repeater>
 

 

</div>
Posted 24-Jan-13 1:13am
Edited 24-Jan-13 1:27am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It's not clear on how you have implemented the pagination. You need to change the CurrentPageIndex on page change.
Following articles should help you:
Pagination with Repeater Control[^]
Custom Paging with the ASP.NET Repeater Control[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 383
1 ChauhanAjay 186
2 Richard Deeming 180
3 Sergey Alexandrovich Kryukov 171
4 Yogesh Kumar Tyagi 165
0 Sergey Alexandrovich Kryukov 6,252
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100