teleerik网格中的回发或回调参数无效



非常著名的错误消息(见下文),从谷歌搜索结果的数量来看。但我见过的每个人都建议将EnableEventValidation设置为false。我已经搜索了我的整个代码库,我找不到字符串"EnableEventValidation"任何地方。此外,这段代码使用来工作;很明显我做了什么把书页弄坏了。但是什么?

当我点击Telerik RadGrid中的按钮时,错误发生了,声明为:

<telerik:RadGrid ID="MyGrid" Width="100%" ItemStyle-BorderColor="Gainsboro"
ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1px" ActiveItemStyle-BackColor="Bisque"
SelectedItemStyle-BackColor="Black" AllowPaging="True" PageSize="15" runat="server"
AllowSorting="true" OnItemCommand="MyGrid_ItemCommand" AutoGenerateColumns="false"
OnNeedDataSource="MyGrid_NeedDataSource" GridLines="Horizontal" AllowMultiRowSelection="false"
Skin="Black">
  <GroupingSettings CaseSensitive="false" />
  <MasterTableView Width="100%" DataKeyNames="ID" AllowFilteringByColumn="false" Font-Names="Arial"
  Font-Size="10px">
    <Columns>
      <telerik:GridButtonColumn ButtonType="PushButton" Text="Cancel" CommandName="Cancel"
      ConfirmText="Are you sure you want to cancel this?">
      </telerik:GridButtonColumn>
      ...
    </Columns>
  </MasterTableView>
  <PagerStyle Mode="NextPrevAndNumeric" />
  <FilterMenu EnableTheming="True">
    <CollapseAnimation Duration="200" Type="OutQuint" />
  </FilterMenu>
</telerik:RadGrid>

点击"取消"按钮,这里是著名的错误:

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.

问题是:在我的Page_Load方法中,我有:

protected void Page_Load(object sender, EventArgs e) {
  MyGrid.Rebind();
}

在回发时重新绑定网格显然是搞砸了什么。我把它改成:

protected void Page_Load(object sender, EventArgs e) {
  if (!IsPostBack) {
    MyGrid.Rebind();
  }
}

现在一切正常

我有同样的问题,但我没有Grid.Rebind()或Grid.Databind()在我的NeedDataSource方法或Page_Load方法。这发生在我拖拽要分组的列,然后对分组列ASC/DESC

排序之后。

我只是添加了

EnableEventValidation="false" 

在我的。aspx页面的<%@ Page %>标签。排序失败了,但至少我不再得到错误。值得注意的是,除了分组列的顺序

之外,其他一切都工作得很好。下面是我在NeedDataSource方法 中使用的代码
        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        String connstr = ConfigurationManager.ConnectionStrings["PrimeIntegartionsConnectionString"].ConnectionString;
        SqlDataSource Ds = new SqlDataSource(connstr, BuildSql()); //buildsql simply returns a SQLSelect String "select * from example"
        RadGrid1.DataSource = Ds;
    }

最新更新