Have to hit LinkButton twice to get ItemCommand event

J

jim corey

I have an app with a single page with a placeholder where I load user
controls for different reports.

On one control which holds a summary report I have a datagrid with
linkbuttons
that cause a detail report to load (I always call the same function in
the main page to load a report.)
From the detail report I hit a button that re-loads the summary
report.

At this point if I hit a linkbutton again the page posts back, but the
ItemCommand event never fires. I hit the linkbutton a second time and
the event fires. Everything else seems the same in terms of code that
gets executed. It's as if there's something in viewstate that
indicates the event
has fired and it won't fire again without another postback.

(Disabling viewstate messes things up, so that's not an option.)

TIA,
Jim
 
T

Teemu Keiski

Hi,

you don't happen to accidentally rebind the the grid on postback or
optionally add the loaded controls on postback event?
 
J

Jim Corey

Teemu,

I don't think so. I've found that one has to be very precise when adding
controls
to a placeholder. When the page posts back, I clear the placeholder and
reload
the current control. I've found that this will insure that viewstate is
still valid and events
(like a button click) will work.
I've used a placeholder rather than put all possible controls on the main
page, which
doesn't seem like a good idea if there's a lot of them.

This approach has worked well up till now. I typically load one of several
controls from
the main page based on a linkbutton event, and then can click on a different
linkbutton
and do it again. In this case I'm doing it a little different, but as far
as I can tell I'm going through
the same code.

End result is that I click, the page does a postback, but the click event
doesn't happen.
I click again and the event happens.

Jim
 

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

Top