繁体   English   中英

无效的回发或回调参数 - Telerik网格中的按钮

[英]Invalid postback or callback argument - button in Telerik grid

非常着名的错误消息(见下文),根据Google搜索结果的数量来判断。 但是我见过的每一个都建议将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();
  }
}

现在一切正常。

我有同样的问题,但我的NeedDataSource方法或Page_Load方法中没有Grid.Rebind()或Grid.Databind()。 这是在我拖动要分组的列然后对分组列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;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM