佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 947|回复: 10

使用update button在datagrid出现的error msg..

[复制链接]
发表于 20-11-2006 10:28 AM | 显示全部楼层 |阅读模式
大家好,我是使用visual studio.net 2005来develop asp.net application的
在我的datagrid里有 "edit button" 用来update我datagrid里dropdownlist的资料,如下:

<asp: DataGrid ID="MyDataGrid" runat="server" AutoGenerateColumns="False" BackColor="LightSalmon"
OnUpdateCommand="MyDataGrid_Update" OnCancelCommand="MyDataGrid_Cancel"
OnEditCommand="MyDataGrid_Edit" OnDeleteCommand="Delete_Item"   
OnPageIndexChanged="MyDataGrid_PageIndexChanged"
DataKeyField="UID"  AllowSorting="True">
<Columns>
<asp: EditCommandColumn ButtonType="PushButton" CancelText="Cancel" EditText="Edit"
  UpdateText="Update"></asp:EditCommandColumn>
<EditItemTemplate>
<asp: DropDownList runat="server" id="edit_status">
<asp: ListItem>ACTIVE</asp: ListItem>
<asp: ListItem>PENDING</asp: ListItem>
</asp: DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn ButtonType="PushButton" CommandName="Delete" Text="Delete"></asp:ButtonColumn>
</Columns>
</asp: DataGrid>

但我一按那个"edit button"就立刻出现以下的error msg.. why?

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.

[ 本帖最后由 counterking 于 20-11-2006 10:42 AM 编辑 ]
回复

使用道具 举报


ADVERTISEMENT

发表于 20-11-2006 11:32 AM | 显示全部楼层
原帖由 counterking 于 20-11-2006 10:28 AM 发表
但我一按那个"edit button"就立刻出现以下的error msg.. why?

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.


你的DATA CONTAINS "<>" --> TAG..
回复

使用道具 举报

 楼主| 发表于 20-11-2006 12:06 PM | 显示全部楼层
对不起, 我不明白你所指的 DATA CONTAINS "<>" --> TAG 是什么?
回复

使用道具 举报

发表于 20-11-2006 12:20 PM | 显示全部楼层
little_orc 的意思是, 当你按 Edit 的时候, 有没有任何一个资料, 或名字有 "<" 或 ">" 的? ASP.NET 会把这当成是 script injection.

另外, 你的 page 里有 Page_Load 这段 code 吗? 那段 code 可能转换了一些 control 的名字而导致这样.
回复

使用道具 举报

 楼主| 发表于 20-11-2006 12:34 PM | 显示全部楼层
请大家refer to 我的datagrid的code..

当我按edit button时,所对应的是dropdownlist..而我相信所用的资料并没有导致script injection的可能
(ACTIVE, PENDING)

其实之前一切还很好,可以按edit button,也可以顺利update.. 但不知为何突然间出error了
会关webconfig的事吗?

<EditItemTemplate>
<asp: DropDownList runat="server" id="edit_status">
<asp: ListItem>ACTIVE</asp: ListItem>
<asp: ListItem>PENDING</asp: ListItem>
</asp: DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>

------------------------------
< -- web.config -- >
------------------------------
<?xml version="1.0"?>
<configuration>
        <appSettings/>
        <connectionStrings/>
        <system.web>
                <compilation debug="true" strict="false" explicit="true"/>
                <pages>
                        <namespaces>
                                <clear/>
                                <add namespace="System"/>
                                <add namespace="System.Collections"/>
                                <add namespace="System.Collections.Specialized"/>
                                <add namespace="System.Configuration"/>
                                <add namespace="System.Text"/>
                                <add namespace="System.Text.RegularExpressions"/>
                                <add namespace="System.Web"/>
                                <add namespace="System.Web.Caching"/>
                                <add namespace="System.Web.SessionState"/>
                                <add namespace="System.Web.Security"/>
                                <add namespace="System.Web.Profile"/>
                                <add namespace="System.Web.UI"/>
                                <add namespace="System.Web.UI.WebControls"/>
                                <add namespace="System.Web.UI.WebControls.WebParts"/>
                                <add namespace="System.Web.UI.HtmlControls"/>
                        </namespaces>
    </pages>
                <authentication mode="Windows"/>
        </system.web>
</configuration>
回复

使用道具 举报

发表于 20-11-2006 01:56 PM | 显示全部楼层
请问你是用Visual Studio .net 2003/2005的吗?
可能你的其中一个RECORDSET的DATA有问题,

或者你可以CLEAR TABLE先,然后Manually insert 一个DATA, 然后在EDIT看看有问题吗. 如果你之前肯定可以用的话,而你又没有改过CODING,
90%是DATA出问题.
回复

使用道具 举报

Follow Us
 楼主| 发表于 20-11-2006 02:12 PM | 显示全部楼层
对! 我是使用visual studio.net 2005的!

还是不行。。。。而且我觉得我按在datagrid里的delete butoon也会出现之前的error msg,
所以应该不关data的问题...



   Sub MyDataGrid_Delete(ByVal s As Object, ByVal e As DataGridCommandEventArgs)

        Dim UID As String
        Dim success As Boolean


        UID = MyDataGrid.DataKeys(e.Item.ItemIndex)

        success = log.delete_member(UID)

        If success = True Then
            log.MessageBox("Record Deleted")
        Else
            log.MessageBox("Error")
        End If

        BindGrid()

    End Sub
--------------------------------------------------------------------------------------------------
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.
回复

使用道具 举报

发表于 20-11-2006 04:39 PM | 显示全部楼层
你试试做看PAGING, 给20/Page.
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 20-11-2006 05:16 PM | 显示全部楼层
试过了, AllowPaging="True" Pagesize="20"

但问题还是一样
回复

使用道具 举报

发表于 21-11-2006 01:44 AM | 显示全部楼层
原帖由 counterking 于 20-11-2006 02:12 PM 发表
还是不行。。。。而且我觉得我按在datagrid里的delete butoon也会出现之前的error msg,
所以应该不关data的问题...


如何觉得?
先试试看 little_orc 在 #6 的做法.
回复

使用道具 举报

 楼主| 发表于 21-11-2006 08:38 AM | 显示全部楼层
昨晚知道原因了。。 是因为form load 的 IsPostBack 作怪。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 24-9-2024 05:22 AM , Processed in 0.111782 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表