请帮忙用C#代码。系统显示回发错误 [英] Please help in C# code. System is showing postback error

查看:52
本文介绍了请帮忙用C#代码。系统显示回发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

系统显示以下错误。



__doPostBack('GridView1 $ ctl02 $ LinkBut​​ton1','')



我是什么尝试过:



system is showing below error while i am clicking on the edit button in the grid view.

__doPostBack('GridView1$ctl02$LinkButton1','')

What I have tried:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowEditing="OnRowEditing">
<columns>
    <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
    <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
    <asp:templatefield>
        <itemtemplate>
            <asp:LinkButton ID="LinkButton1" Text="Edit" runat="server" CommandName="Edit" />
        
        <edititemtemplate>
            <asp:LinkButton ID="LinkButton2" Text="Update" runat="server" OnClick="OnUpdate" />
            <asp:LinkButton ID="LinkButton3" Text="Cancel" runat="server" OnClick="OnCancel" />

推荐答案

ctl02


LinkBut​​ton1','')



我尝试过:



LinkButton1','')

What I have tried:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowEditing="OnRowEditing">
<columns>
    <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
    <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
    <asp:templatefield>
        <itemtemplate>
            <asp:LinkButton ID="LinkButton1" Text="Edit" runat="server" CommandName="Edit" />
        
        <edititemtemplate>
            <asp:LinkButton ID="LinkButton2" Text="Update" runat="server" OnClick="OnUpdate" />
            <asp:LinkButton ID="LinkButton3" Text="Cancel" runat="server" OnClick="OnCancel" />


1)GridView问题中的无效回发或回调参数m可能是:您正在使用对象数据源或带有函数调用的手动绑定将Page_Load事件中的数据绑定。这将使你的GridView在任何控件的每个事件触发时绑定数据。



当你使用OnRowCommand触发任何GridView命令时,在RowCommand触发之前你的GridView将重新绑定并且所有其中的控件将被分配给新的id。因此RowCommand无法获取已触发事件的项目。



GridView中无效回发或回调参数的解决方案:您可以在此条件下绑定您的数据



if(!IsPostBack)

{

//你的Bind数据代码

}
1) Invalid Postback or Callback argument in GridView Problem may be: You are binding data in Page_Load event with either Object Data Source or Manual Binding with function call. This will make your GridView bind data on every event fire of any control.

When you are firing any GridView command with OnRowCommand, before RowCommand fire your GridView will rebind and all control within it will be assigned to new id. So RowCommand could not get the item which have fired the event.

Solution for Invalid Postback or Callback argument in GridView: You can bind your data within this if condition

if (!IsPostBack)
{
//Your code for Bind data
}


这篇关于请帮忙用C#代码。系统显示回发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆