Gridview rowupdating事件无法获取新值.... [英] Gridview rowupdating event not able to get New values....

查看:68
本文介绍了Gridview rowupdating事件无法获取新值....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gridview中使用BoundFields将数据绑定到gridview ...在行更新事件中,我只获得旧值。我没有得到新输入的值...为什么会发生这样的...

i am using BoundFields in gridview to bind the data to gridview...In row updating event i am getting old values only.i am not getting newly entered values ...why it is happening like that...

<Columns>
    <asp:BoundField DataField="latitude" HeaderText="Latitude" />
    <asp:BoundField DataField="Longitude" HeaderText="Longitude" />
</Columns>




protected void gvAlerts_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
      GridViewRow row = gvAlerts.Rows[e.RowIndex];
      string Latitude = ((TextBox)(row.Cells[1].Controls[0])).Text;
      string Longitude = ((TextBox)(row.Cells[2].Controls[0])).Text;           
}



这里的纬度和经度,我只得到旧的值....没有得到新输入的值..... />
为什么只获得旧值?


Here in latitude and longitude, i am getting the old values only....not getting the newly entered values.....
why it is getting old values only?

推荐答案

亲爱的朋友,



在gridview rowupdating事件中,该行实际上未更新。它会在更新前处理该行的事件。



请通过以下链接查看;您将了解代码中的问题。



GridView.RowUpdating事件



请不要忘记将此标记为您的答案,如果它可以帮助您。



问候



Varun Sareen
Dear Friend,

In gridview rowupdating event, the row is not actually updated. It handles the event for the row before updates.

Please go through the link below; you will get to know the problem in your code.

GridView.RowUpdating Event

Please don''t forget to mark this as your answer if it helps you out.

Regards

Varun Sareen


我认为当您点击更新链接时,Gridview会在获取新值之前再次绑定。



你必须忘记在 GridView.DataBind()之前忘记使用 if(!IsPostBack)



理想情况下,在绑定之前,您应该检查下面的内容......



I think when you click update link, Gridview is binding again before taking new value.

You must have forgotten to use if(!IsPostBack) before GridView.DataBind().

Ideally before binding you should check that like below...

if(!IsPostBack)
{
    // Code to bind the GridView.
}


这篇关于Gridview rowupdating事件无法获取新值....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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