Tuesday, August 26, 2008

GridView 'Edit' Request With IsPostBack False

This seemed to be a weird one... I was getting two requests from my Page with GridView, one with IsPostBack false and another with IsPostBack true whenever I clicked the Edit image. As I was setting the master page in the PreInit event based on UrlReferrer and IsPostBack (the UrlReferrer is the same as the current page for postback requests - both normal and the weird ones that GridView is causing), this was wreaking havoc on the page.

A possible workaround for the GridView edit-images bug is to use TemplateFields with ImageButtons, or use text instead of images by removing the ButtonType="Image" attribute setting. I got a tip suggesting the use of ScriptManager.GetCurrent(Page).IsInAsyncPostBack instead of IsPostBack.

No comments: