GridView控件上编辑的事件,在更新事件? [英] gridview on edit event , on update event?

查看:150
本文介绍了GridView控件上编辑的事件,在更新事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我怎么可以访问 GridView控件?结果的编辑和更新按钮
我的意思是,如果我从 GridView控件的网站点击编辑按钮,我想从表中得到一些价值。结果
例如:在按钮1 事件

I would like to know how I can access the edit and the update button from GridView?
I mean, if I click the edit button from the website in the GridView, I want to get some values from the tables.
For example: the button1 event.

推荐答案

您可以利用GridView的RowUpdating事件的。

You could make use of the GridView rowupdating event.

protected void myGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)

GridViewUpdateEventArgs 包含 NewValues​​ 属性和 OldValues​​

我经常使用以下方法来取消更新,如果没有实际上已经改变。

I often use the following to cancel the update if nothing has actually been changed.

foreach (DictionaryEntry d in e.NewValues)
{
    String oldValue = e.OldValues[d.Key] == null ? "" : e.OldValues[d.Key].ToString();
    String newValue = d.Value == null ? "" : d.Value.ToString();
    if (oldValue != newValue)
    {                    
        return; // -- change detected
    }
}
e.Cancel = true; // -- don't execute the update
myGridView.EditIndex = -1;

这篇关于GridView控件上编辑的事件,在更新事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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