Click here to Skip to main content
12,757,627 members (36,489 online)
Rate this:
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
if (ViewState["PageNumber"] != null)
return Convert.ToInt32(ViewState["PageNumber"]);
return 0;
ViewState["PageNumber"] = value;

int Qid;
protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)

if (Request.QueryString["id"] != null)



protected override void OnInit(EventArgs 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;


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

// DataList1.Visible = false;


rptPages.Visible = false;
//DataList1.Visible = true;
DataList1.DataSource = pgitems;


protected void rptPages_ItemCommand(object source, RepeaterCommandEventArgs e)
PageNumber = Convert.ToInt32(e.CommandArgument) - 1;

My Design
<div class="que-panel">

<asp:Repeater ID="rptPages" Runat="server" onitemcommand="rptPages_ItemCommand" >
<table cellpadding="0" cellspacing="0" border="0">
<td><b>Page:</b> </td>

<asp:LinkButton ID="btnPage"
Container.DataItem %>"
Runat="server"><%# Container.DataItem %>

<asp:Repeater ID="DataList1" runat="server"
<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>



Posted 24-Jan-13 2:13am
Updated 24-Jan-13 2:27am

1 solution

Rate this: bad
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[^]

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2017
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