Grid - ajax postback error

2 posts, 0 answers
  1. ThomasJ
    ThomasJ avatar
    11 posts
    Member since:
    Dec 2007

    Posted 28 Apr 2008 Link to this post

    I have trouble with my masterpage after changing to Q1 2008 of the  RadControls for 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)

  2. ThomasJ
    ThomasJ avatar
    11 posts
    Member since:
    Dec 2007

    Posted 28 Apr 2008 Link to this post

    I found the solution in an 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.

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top