如何修改输入数据DetailsView控件的ItemUpdating事件? [英] How to modify input data in ItemUpdating Event of Detailsview?

查看:226
本文介绍了如何修改输入数据DetailsView控件的ItemUpdating事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果
你能告诉我我怎么可以访问ItemUpdating事件DetailsView控件的输入数据?
结果
我想要做数据的用户输入的DetailsView一些修改。
谢谢


Can you direct me how can i access input data of DetailsView in ItemUpdating event ?
I want do some modification on data that user input to Detailsview . Thank you

推荐答案

DetailsView控件控件的 ItemUpdating 事件具有参数同时包含原始数据(如果可用),以及新的数据,用户在键入下面是如何检查数据,并有选择地修改它的一个例子:

The DetailsView control's ItemUpdating event has arguments that contain both the original data (if available) as well as the new data that the user typed in. Here's an example of how to check the data and optionally modify it:

private void OnDetailsViewItemUpdating(object sender, DetailsViewUpdateEventArgs e) {
    if (String.Equals((string)e.NewValues["firstName"], "john", StringComparison.OrdinalIgnoreCase)) {
        // "John" is not a valid name, so change it to "Steve":
        e.NewValues["firstName"] = "Steve";
    }
    if (String.Equals((string)e.NewValues["lastName"], "doe", StringComparison.OrdinalIgnoreCase)) {
        // If "Doe" is the last name, cancel the whole operation
        e.Cancel = true;
    }
}

请参阅MSDN上的更多信息<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsviewupdateeventargs.aspx\"相对=nofollow> DetailsViewUpdateEventArgs 类型。

See MSDN for more info on the DetailsViewUpdateEventArgs type.

这篇关于如何修改输入数据DetailsView控件的ItemUpdating事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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