This is information for those who may have been bitten by the
"double-post" problem in GridView controls. I've been messing with
ASP.Net about a week, and have uncovered an annoying 'feature'.
Never bothered with Net 1.x, and have stuck with cASP so far...
Summary:
--------------------
When the Command Field consists of a button or text, the control
behaves properly. When an image is used, it does not.
After studying the HTML generated and sent to the client, I have
determined the following:
When TEXT is used, the __doPostBack javascript code is attached.
When BUTTON is used, it does not attach the __do PostBack code.
Instead, it uses the browser's intrinsic behavior to post.
The Bug
-----------------
Now this is where the beast rears it's ugly head...
When IMAGE is used, ASP.Net attaches the __do PostBack code to the
image's OnClick() event, but the image is also defined as an <INPUT>.
So, the browser engine generates a postback as well. This leads to a
double postback to the server.
Workaround
----------------------
A temporary solution is to manually create a Template Field to
encapsulate the image(s), rather then the built in Command Field.
ASP.Net does NOT attach the __doPostBack code to the image's onClick
event when in a Template Field.
Solution
---------------
The proper solution is to alter this behavior in ASP.Net.
And while you're at it, how about the <TABLE> idiosyncrasies of IE?
( cellpadding and cellspacing ) Rather than defining a CSS style for
these, you have to format inline in the page markup. It's been 10
years now... How about it, Bill? ;-)
FWIW,
Greg G.