Advertisement:

Skystone Software

http://www.SkystoneSoftware.com

Scott Waletzko's Blog - Latest Entry

ImageButton + GridView + RowCommand = (Grid_RowCommand X 2)
Published: 5/12/2009

Some fun with Microsoft Math for a minute - tonight I ran into an undocumented "feature" of .NET 2.0 that is frustrating to say the least. If you use an ImageButton in a GridView to trigger a RowCommand event, it will fire the event twice. Fortunately, there's a way to test for the second, false trigger - just look for the image co-ordinates being passed along in the request:

C#
protected void gridData_RowCommand(object sender, GridViewCommandEventArgs e)
{
    // undocumented bug with ImageButton - fires the command twice...
    if (this.Request["x"] == null || this.Request["y"] == null) { return; }
	// process real request etc...
	
}
	

Questions or Comments? .