This is a migrated thread and some comments may be shown as answers.

Grid - ajax postback error

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ThomasJ
Top achievements
Rank 2
ThomasJ asked on 28 Apr 2008, 01:43 PM

Hi.
I have trouble with my masterpage after changing to Q1 2008 of the  RadControls for asp.net Ajax

In my masterpage I have a calender and a grid working together. When I click the calendar the grid updates with som data. in the grid i have 2 imagebuttons in each row, theese two takes me to a "register" page. During itemdatabound each button is given a spesific postbackurl according to the dataId of that row.

So far so good. But when I click one of the buttons the new page is loaded just fine, but if I click either of the buttons a second time(in case I wanted the other item) then a Javascript or a server error occurs. in both the server error and the javascript error the same thing is presented. EnableEventValidation=true. set the event validation false. I dont want to do that, can you help me? I've pasted the stacktrase from the serverside error:

System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +2132728
   System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +108
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +32
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


1 Answer, 1 is accepted

Sort by
0
ThomasJ
Top achievements
Rank 2
answered on 28 Apr 2008, 07:13 PM
I found the solution in an asp.net forum

This is a known "bug" apparently. The issiue here is imagebuttons inside a grid.
The error then occurs because the grids row id is different on each postback/callback. All this is solved by adding a unique id on each row each time it is loaded.

exsample
as an global variable add a
protected int counter = 1;

in the ItemDataBound methode
add the line 

e.Item.ID = string.Format("datarow_{0}", counter);


this insures that each row are named uniqly and the same name is generated on each post or callback.

Tags
Grid
Asked by
ThomasJ
Top achievements
Rank 2
Answers by
ThomasJ
Top achievements
Rank 2
Share this question
or