handle imagebutton click in gridview
-
Dear All, I am placing an image button inside a gridview: | | | protected void equipmentGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandSource=="image") { Response.Redirect("http://www.google.com"); } } I want to be able to handle the click of the imagebutton. I tried using onrowcommand but the application is not even accessign the method it just returns an in valid postback error. I tried modifying the event validation to true but no success. the error does not pop up but the method is still not invoked. Thanks a lot Chris
-
Dear All, I am placing an image button inside a gridview: | | | protected void equipmentGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandSource=="image") { Response.Redirect("http://www.google.com"); } } I want to be able to handle the click of the imagebutton. I tried using onrowcommand but the application is not even accessign the method it just returns an in valid postback error. I tried modifying the event validation to true but no success. the error does not pop up but the method is still not invoked. Thanks a lot Chris
Change your if statement to check the e.CommandName instead of e.CommandSource.
if(e.CommandName == "imageClick") { Response.Redirect("http://www.google.com"); }
I also noticed that your ImageButton id said i="image" instead of id="image" but that could just be a typo. Nathan