Event firing alternates

M

mazdotnet

Hi guys,

I'm running into a little problem I was hoping someone has experienced
before or knows a why a workaround. I'm generating a navigation menu
on my database resultsets that would show you the next and previous
pages. However, it only fires the first time and the alternating
times. So when I click page 1 it works, then page 2 first time fails,
next time after that worksworks. Here's my code

for (int x = minRange; x <= maxRange; x++)
{
if (x == pageIndex)
{
Label lbPageIndex = new Label();
lbPageIndex.Text = x.ToString();
phListNav.Controls.Add(lbPageIndex);
}
else
{
LinkButton lbNav = new LinkButton();
lbNav.Text = x.ToString();
lbNav.CssClass = "paging1";
lbNav.CommandArgument = x.ToString();
lbNav.Command += new
CommandEventHandler(lbNav_Command);
phListNav.Controls.Add(lbNav);
}
}


protected void lbNav_Command(object sender, CommandEventArgs e)
{
pageIndex = int.Parse(e.CommandArgument.ToString());
BindSearchResults();
}

So it works on every other click starting with the first one. Any idea
why this might be happening?

Thx
Maz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top