problem with GridView and PostBack

  • Thread starter Thread starter Jeff
  • Start date Start date
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?
 
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
 
Back
Top