- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在使用 gridview 单击按钮时出现以下错误
Server Error in '/' Application.
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: 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.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: 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.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +144
System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +29
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
当我在 gridview 中按下一个按钮时会发生这种情况,奇怪的是我有另一个 gridview,在运行不同代码的列中也有自定义按钮,但没有给出错误。以下是页面和代码隐藏的代码。
namespace CCCC
{
public partial class drivermangement : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
{
if (Roles.IsUserInRole("Administrator"))
{
LoggedInUser.Value = Convert.ToString(Request.QueryString["driver"]);
}
else
{
LoggedInUser.Value = Membership.GetUser().UserName.ToString();
}
DayOfTheWeekHiddenField.Value = Convert.ToString(Request.QueryString["dow"]);
}
else
{
Response.Redirect("default.aspx");
}
if (NewCustomersGrid.Rows.Count == 0)
{
NewCustomersLabel.Visible = false;
}
else
{
NewCustomersLabel.Visible = true;
}
if (NeedCompostGrid.Rows.Count == 0)
{
NeedCompostLabel.Visible = false;
}
else
{
NeedCompostLabel.Visible = true;
}
if (CanceledGrid.Rows.Count == 0)
{
CanceledLabel.Visible = false;
}
else
{
CanceledLabel.Visible = true;
}
if (VacationGrid.Rows.Count == 0)
{
VacationLabel.Visible = false;
}
else
{
VacationLabel.Visible = true;
}
if (NewCustomersGrid0.Rows.Count == 0)
{
NewCustomersLabel0.Visible = false;
}
else
{
NewCustomersLabel0.Visible = true;
}
if (NeedCompostGrid0.Rows.Count == 0)
{
NeedCompostLabel0.Visible = false;
}
else
{
NeedCompostLabel0.Visible = true;
}
if (CanceledGrid0.Rows.Count == 0)
{
CanceledLabel0.Visible = false;
}
else
{
CanceledLabel0.Visible = true;
}
}
protected void NewCustomerDoneButton_Click(object sender, EventArgs e)
{
int CustomerID = Convert.ToInt32(((Button)sender).CommandArgument);
string CustomerBinNeedAcknowledged = "Yes";
string strConnString = "Data Source";
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE Customers SET CustomerBinNeedAcknowledged=@CustomerBinNeedAcknowledged WHERE CustomerID=@CustomerID";
cmd.Parameters.AddWithValue("@CustomerBinNeedAcknowledged", CustomerBinNeedAcknowledged);
cmd.Parameters.AddWithValue("@CustomerId", CustomerID);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
和实际页面:
<%@ Master Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" Inherits="CCCCCC.drivermangement" CodeBehind="drivermangement.master.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:HiddenField ID="LoggedInUser" runat="server" />
<asp:HiddenField ID="DayOfTheWeekHiddenField" runat="server" />
<ajaxToolkit:TabContainer ID="RoutingTabs" runat="server" ActiveTabIndex="0"
Width="900px">
<ajaxToolkit:TabPanel runat="server" HeaderText="Pre-Route" ID="PreRouteTab">
<ContentTemplate>
<br />
<asp:Label ID="NewCustomersLabel" runat="server"
style="font-weight: 700; font-size: large; color: #009933" Text="New Customers"></asp:Label>
<asp:GridView ID="NewCustomersGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
DataKeyNames="CustomerId" DataSourceID="NewCustomers" ForeColor="Black"
GridLines="Vertical">
<AlternatingRowStyle BackColor="#99FF99" ></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="CustomerFullName" HeaderText="Name"
SortExpression="CustomerFullName" />
<asp:BoundField DataField="CustomerFullAddress" HeaderText="Address"
SortExpression="CustomerFullAddress" />
<asp:BoundField DataField="CustomerNeedsBin" HeaderText="Needs Bin?"
SortExpression="CustomerNeedsBin" />
<asp:TemplateField ShowHeader="False"><ItemTemplate>
<asp:Button ID="NewCustomerDoneButton" runat="server" CommandName=""
Text="Done" CommandArgument='<%# Eval("CustomerID") %>' OnClick="NewCustomerDoneButton_Click" CausesValidation="False" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<asp:SqlDataSource ID="NewCustomers" runat="server"
ConnectionString="<%$ ConnectionStrings:tcc_customersConnectionString %>"
SelectCommand="SELECT [CustomerId], [CustomerStatus], [CustomerFullName], [CompanyName], [CustomerFullAddress], [CustomerPickUpDay], [CustomerPickUpDay2], [CustomerDriver], [CustomerNeedsBin], [CustomerBinNeedAcknowledged] FROM [Customers] WHERE (([CustomerBinNeedAcknowledged] = @CustomerBinNeedAcknowledged) AND ([CustomerNeedsBin] = @CustomerNeedsBin) AND ([CustomerDriver] = @CustomerDriver) AND ([CustomerStatus] = @CustomerStatus) AND ([CustomerPickUpDay] = @CustomerPickUpDay OR [CustomerPickUpDay2] = @CustomerPickUpDay2))"><SelectParameters>
<asp:Parameter DefaultValue="No" Name="CustomerBinNeedAcknowledged" Type="String" />
<asp:Parameter DefaultValue="Yes" Name="CustomerNeedsBin" Type="String" />
<asp:ControlParameter ControlID="LoggedInUser" Name="CustomerDriver"
PropertyName="Value" Type="String"></asp:ControlParameter>
<asp:Parameter DefaultValue="New" Name="CustomerStatus" Type="String" />
<asp:ControlParameter ControlID="DayOfTheWeekHiddenField" Name="CustomerPickUpDay"
PropertyName="Value" Type="String" ></asp:ControlParameter>
<asp:ControlParameter ControlID="DayOfTheWeekHiddenField"
Name="CustomerPickUpDay2" PropertyName="Value" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel runat="server" HeaderText="Post-Route" ID="PostRouteTab"><ContentTemplate>
我现在想知道,这与 GridView
位于 Ajax Tab Container
内有什么关系吗?因为我的另一张工作正常的 table 不是......
注意:由于字符限制,不得不从页面中删除一些代码
最佳答案
1) GridView 中无效的回发或回调参数 问题可能是:您正在将 Page_Load 事件中的数据与对象数据源或手动绑定(bind)与函数调用绑定(bind)。这将使您的 GridView 在任何控件的每个事件触发时绑定(bind)数据。
当您使用 OnRowCommand 触发任何 GridView 命令时,在 RowCommand 触发之前,您的 GridView 将重新绑定(bind)并且其中的所有控件都将分配给新的 ID。所以 RowCommand 无法获取触发事件的项目。
GridView 中无效回发或回调参数的解决方案:您可以在此 if 条件中绑定(bind)您的数据
if (!IsPostBack)
{
//Your code for Bind data
}
这段代码肯定会给你解决方案,如果这不起作用,然后检查是否有任何其他控件没有给出错误。
关于c# - 错误 : Invalid postback or callback argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12444946/
例如,如果我的程序名称是 test.c 然后对于以下运行命令,argc = 2 而不是 4。 $test abc pqr* *xyz* 最佳答案 尝试运行: $ echo abc pqr* *xyz*
我正在尝试使用一个容器来显示TextField,但是该容器不喜欢我的操作顺序。这是我的代码: Widget build(BuildContext context) { return Scaffol
我有以下代码: class MetricGoogleGateway extends AMetricGateway{ constructor(id, name, token) {
我像这样调用下面的对象方法。 new Cout( elem1 ).load( 'body' ) new COut( elem1 ).display( 'email' ) 我一次只使用一个实例。因为我一
我正在尝试使用 C++11 中的可变参数函数模板,并通过如下代码了解了基本思想: void helper() { std::cout void helper( T&& arg ) {
在学习 ExtJS 4 时,我发现在定义一个新类时,在 initComponent 中方法可以使用 this.callParent(arguments) 调用父类的构造函数. 我想知道这个 argum
使用 XCode 9,Beta 3。Swift 4。 statsView.createButton("Button name") { [weak self] Void in //stuff st
以下代码将打印1: (function (arguments) { console.log(arguments); }(1, 2)); 实际上,arguments 对象已被覆盖。是否可以恢复函
/** * @param $name * @return Response * @Route ("/afficheN/{name}",name="afficheN") */ public fu
我习惯使用Scala scopt用于命令行选项解析。您可以选择参数是否为 .required()通过调用刚刚显示的函数。 如何定义仅在定义了另一个参数时才需要的参数? 例如,我有一个标志 --writ
所以这是我的代码: def is_valid_move(board, column): '''Returns True if and only if there is an o
我试图在这里运行此代码: threads = [threading.Thread(name='ThreadNumber{}'.format(n),target=SB, args(shoe_type,m
在静态类型函数编程语言(例如 Standard ML、F#、OCaml 和 Haskell)中,编写函数时通常将参数彼此分开,并通过空格与函数名称分开: let add a b = a + b
function validateArguments(args) { if(args.length 2) { throw new RangeError("Invalid amo
我正在使用 Django 1.5 并尝试将参数传递到我的 URL。当我使用前两个参数时,下面的代码工作正常,使用第三个参数时我收到错误。我已经引用了新的 Django 1.5 更新中的 url 用法,
我刚刚开始使用 ember js 并且多次被这个功能绊倒 有人可以简要介绍一下 this._super() 的使用,并解释 ...arguments 的重要性 谢谢 最佳答案 每当您覆盖类/函数(例如
这个问题在这里已经有了答案: How to fix an "Argument passed to call that takes no arguments" error? (2 个答案) 关闭 3
我正在创建一个简单的登录注册应用程序。但是我遇到了错误,我不知道如何解决,请帮忙!这是我的代码: // // ViewController.swift // CHLogbook-Applicati
我是 Swift 的初学者。我尝试创建一个表示 Meal 的简单类。 它有一些属性和一个返回可选的构造函数 但是当我尝试测试它或在任何地方实例化它时,我得到的只是一个错误。似乎无法弄清楚发生了什么。
我有一个在特殊环境下运行其他程序的系统程序: cset shield -e PROGRAM .现在要运行一个 java 程序,我输入了 cset shield -e java PROGRAM ,但这不
我是一名优秀的程序员,十分优秀!