我在GridView中放了一个Button,想要执行Button引发的RowCommand可是在点击Button时出现如下错误提示.
回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
以下是出错的Button:
<asp:TemplateField HeaderText="操作">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" Width="30%" />
<ItemTemplate>
<asp:Button ID="ImageButton1" runat="server" CommandArgument='<%#Eval("Url") %>' Visible='<%# !(bool)DataBinder.Eval(Container.DataItem,"Flag")%>' CommandName="download" />
</ItemTemplate>
</asp:TemplateField> 以下是定义的RowCommand:
protected void DiskView_RowCommand(object sender,GridViewCommandEventArgs e)
{
if (e.CommandName == "download")
{
/// 执得的操作
}
}
回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
以下是出错的Button:
<asp:TemplateField HeaderText="操作">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" Width="30%" />
<ItemTemplate>
<asp:Button ID="ImageButton1" runat="server" CommandArgument='<%#Eval("Url") %>' Visible='<%# !(bool)DataBinder.Eval(Container.DataItem,"Flag")%>' CommandName="download" />
</ItemTemplate>
</asp:TemplateField> 以下是定义的RowCommand:
protected void DiskView_RowCommand(object sender,GridViewCommandEventArgs e)
{
if (e.CommandName == "download")
{
/// 执得的操作
}
}
是对 的。