problem with GridView and PostBack

J

Jeff

hi

asp.net 2.0

I have a GridView on a custom web control. This GridView has a Template
field containing among others a ButtonLink. When I click on that link the
data in that row is modified in the database. This field is a counter, it
increasing with 1 each time clicked

Okay, but after I clicked on that buttonlink and made that modification to
the database, I can then click Refresh in the internet browser and the field
in the database is updated again. This is not something I want....

So I went about to place the code inside an if-test:
protected void lbTest_Command(object sender, CommandEventArgs e)
{
if (!Page.IsPostBack)
{
//logic here
}
}

But now the code isn't even executed when I click on that button...

any suggestions?
 
P

PJ on Development

Hi, Jeff

The problem is more basic.

It happens because when you refresh the page the broswer sends another
request to the page, causing another PostBack.

And the click event occurs only during the PostBack event.

Regards,

Paulo Santos
http://pjondevelopment.50webs.com
 

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,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top