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

Telerik RadGrid : Invalid postback or callback argument

4 Answers 1107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ju
Top achievements
Rank 1
Ju asked on 06 Jun 2011, 02:12 PM
Hello,

I'm trying to see all the benefits of telerik components for a project. I'm trying to display a insert/update/delete grid on a web page. I'm working with the framework 4.0. The version of the Telerik.Web.UI.dll is 2011.1.519.40

My problem is, when i'm choose the edit button, i've got a error message

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

 

I searched on the internet about this problem but didn't find a real answer.
I can't assign false value the validationEvent tag as it's not secure.

Do you have any idea ?
Here is my code (quite simple)
My Content page

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
   CodeBehind="ListeFormateurs.aspx.cs" Inherits="ProtoFTCartoAjax.ListeFormateurs" %>
  
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
   Ceci est la liste des formateurs<br />
   <br />
   <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="True" EnableViewState="True">
      <MasterTableView CommandItemDisplay="Top" DataKeyNames="Identifiant" AutoGenerateColumns="False" EditMode="InPlace"
      >
         <Columns>
            <telerik:GridEditCommandColumn ButtonType="PushButton" UniqueName="EditCommandColumn">
               <HeaderStyle Width="85px"></HeaderStyle>
            </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn UniqueName="FirstName" HeaderText="First name"
                        DataField="Nom" />
<telerik:GridBoundColumn UniqueName="LastName" HeaderText="Last name"
                        DataField="Prenom" />
         </Columns>
      </MasterTableView>
   </telerik:RadGrid>
</asp:Content>

My aspx.cs page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
  
namespace ProtoFTCartoAjax
{
   public partial class ListeFormateurs : System.Web.UI.Page
   {
      protected void Page_Load(object sender, EventArgs e)
      {
            List<FormateurDto> liste = FormateurFactory.SelectAll();
            RadGrid1.DataSource = liste;
            RadGrid1.DataBind();
      }
   }
}

Thanks for your time

4 Answers, 1 is accepted

Sort by
0
Ju
Top achievements
Rank 1
answered on 06 Jun 2011, 02:20 PM
I don't really knnow why but I used the OnNeedDatasource event and i don't have this problem anymore.
0
christian
Top achievements
Rank 1
answered on 30 Nov 2011, 05:30 PM
yes, solved it!

don't rebind in your postback/pageload
this worked for me:
protected void RadGrid_OnDataSourceNeeded(object sender, EventArgs e)
        {
           DataTable table = GetTableFromCache();
           RadGridSchadePremieRapport.DataSource = table;
       //now no rebind() or databind() !
        }
0
Shinu
Top achievements
Rank 2
answered on 01 Dec 2011, 05:37 AM
Hello Ju,

When you are implementing any advanced features in RadGrid like paging, grouping, editing etc, you should bind the grid with advanced data binding using its NeedDataSource event. Check the following help documentation which explains more about this.
Advanced Data-binding (using NeedDataSource event)

-Shinu.
0
Alex Fuernsinn
Top achievements
Rank 1
answered on 25 Jun 2014, 07:04 AM
Yesss! That's it.
Just DON'T Rebind after OnDataSourceNeeded
thx.
Tags
Grid
Asked by
Ju
Top achievements
Rank 1
Answers by
Ju
Top achievements
Rank 1
christian
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Alex Fuernsinn
Top achievements
Rank 1
Share this question
or