Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Paging using repeater control

Reply
Thread Tools

Paging using repeater control

 
 
Eugene Anthony
Guest
Posts: n/a
 
      02-09-2007
The problem with my coding is that despite removing the records stored
in the array list, the rptPages repeater control is till visible. The
rptPages repeater control displayes the navigation link (1,2,3 so on).
The code is as bellow:



using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Data.SqlClient;
using MyProject;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
BindData();
UpdateSubCounter();
}

public int PageNumber
{
get
{
if (ViewState["PageNumber"] != null)
return Convert.ToInt32(ViewState["PageNumber"]);
else
return 0;
}
set
{
ViewState["PageNumber"] = value;
}
}

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

public void BindData()
{
String GroupID = Request.QueryString["GroupID"];

if (GroupID != null)
{
Subscription sub = new Subscription();
sub.groupid = int.Parse(GroupID.ToString()); //1;
sub.memberid = 2;

if (((ArrayList)this.Session["Address"]).Contains(sub) ==
false)
{
((ArrayList)this.Session["Address"]).Add(sub);
LoadData();
}
else
{
LoadData();
}
}
else
{
LoadData();
}
}

public void LoadData()
{
PagedDataSource pgitems = new PagedDataSource();
pgitems.DataSource = ((ArrayList)this.Session["Address"]);
pgitems.AllowPaging = true;
pgitems.PageSize = 1;
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();
}
else
{
rptPages.Visible = true;
}

rptItems.DataSource = pgitems;
rptItems.DataBind();
}

public void UpdateSubCounter()
{
int numSubscription;
numSubscription = ((ArrayList)this.Session["Address"]).Count;
Label2.Text = numSubscription.ToString();

if (numSubscription == 0)
{
HyperLink1.Enabled = false;
LinkButton1.Enabled = false;
}
}

protected void LinkButton1_Click(object sender, EventArgs e)
{
for (int rowindex = 0; rowindex <
((ArrayList)this.Session["Address"]).Count; rowindex++)
{
Subscription m =
(Subscription)((ArrayList)this.Session["Address"])[rowindex];
SqlConnection cnn = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["myConnection"].Con
nectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = cnn;
myCommand.CommandText = "INSERT subscription VALUES(" +
m.groupid + "," + m.memberid + ")";
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);
DataSet ds = new DataSet();
myAdapter.Fill(ds, "subscription");
}

Response.Redirect("SubscriptionListing.aspx");
}
protected void rptItems_ItemCommand(object source,
RepeaterCommandEventArgs e)
{
LinkButton m = (LinkButton)e.Item.FindControl("LinkButton2");
int rowindex = m.TabIndex;

((ArrayList)this.Session["Address"]).Remove(((ArrayList)this.Session["Ad
dress"])[rowindex]);
LoadData();
UpdateSubCounter();
}

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


How do I solve the problem?.


Regards


Eugene Anthony

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ASP.NET 2.0] Repeater control & paging, how?? Jeff ASP .Net 2 03-20-2007 05:15 PM
Paging using repeater control Eugene Anthony ASP .Net 0 02-09-2007 04:55 AM
paging using repeater control aspnetdir ASP .Net Web Controls 1 04-30-2006 09:33 AM
Search & Paging using Repeater control. ratnakarp@gmail.com ASP .Net 1 09-01-2005 08:50 PM
implementing paging with a repeater control using VBScript darrel ASP .Net Web Controls 1 03-06-2004 01:00 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57