Just change the "CommandNam e" property of the "Edit" button from "Edit" to "EditRow"(o r something else which is relevent to you but make sure it is not "Edit"). Now surprisingly the code works fine.