473,386 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problem with GridView and PostBack

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?
Oct 16 '08 #1
1 1830
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

On Oct 16, 7:39*pm, "Jeff" <it_consulta...@hotmail.com.NOSPAMwrote:
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?
Oct 17 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Simon Strandgaard | last post by:
Hi group, my setup: I have a GridView that extracts data from my table (a SqlDataSource). For each row, I have an 'edit' button and a 'delete' button. The 'edit' button opens a popup, through...
4
by: Chuck | last post by:
I'm setting the column with for a gridview (25+- columns) and have paging turned on. When the gridview is first displayed, the column widths are all set to the default. But after paging to...
6
by: Greg | last post by:
Hello, I have a GridView bound to a custom object. I set the DataKeyNames property along with the column DataField properties at design time, and bind the GridView to my object at run-time. In...
1
by: Jeff | last post by:
ASP.NET 2.0 I've got problems with the right column in my GridView. The GridView consist of 2 columns, the problem column is the column on the right side. The problem is that it looks like...
1
by: =?Utf-8?B?V2VzbGV5IERhdmlzLCBHZW5lcmFsIER5bmFtaWNz | last post by:
I'm moving from years with the datagrid to a new project, .net 2.0, using GridView controls. Per past practice, it is often a lot easier to inject controls (or special formatting) in RowDataBound...
2
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files...
0
by: db007 | last post by:
I have a problem at the moment with a web project. I have two Panels within an UpdatePanel on an aspx page (using Masterpages). I'm using ASP.Net 2.0 with an AJAX enabled website. The two...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
4
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.