Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法更新.net中的gridview值_C#_Asp.net_Gridview - Fatal编程技术网

C# 无法更新.net中的gridview值

C# 无法更新.net中的gridview值,c#,asp.net,gridview,C#,Asp.net,Gridview,在更新gridview记录时。旧值只能更新。我正在使用绑定字段。在im获取变量中的数据时获取旧值 <asp:GridView runat="server" ID="GvLeads" AutoGenerateColumns="false" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" OnRowDeleting="GvLeads_RowDeleting" OnRowEditing="GvLeads_RowEditi

在更新gridview记录时。旧值只能更新。我正在使用绑定字段。在im获取变量中的数据时获取旧值

<asp:GridView runat="server" ID="GvLeads" AutoGenerateColumns="false" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" OnRowDeleting="GvLeads_RowDeleting" OnRowEditing="GvLeads_RowEditing" OnRowCancelingEdit="GvLeads_RowCancelingEdit" EmptyDataText="No Records Found" OnRowUpdating="GvLeads_RowUpdating" OnRowDeleted="GvLeads_RowDeleted">
 <Columns>
    <asp:BoundField HeaderText="Id" DataField="LeadId" />
    <asp:BoundField HeaderText="Company" DataField="Companyname" />
 </Columns>
</GridView >

这通常发生在您在
Page\u Load
上填充网格时,只要在调用
Page\u Load
事件之前调用了
rowupdateing
事件get,该事件使用初始值填充网格。如何避免?使用
!iPostback
为此目的

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        BindGrid(); // For e.g.
    }
}

欢迎光临,很高兴帮助您。
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        BindGrid(); // For e.g.
    }
}