在gridview中捕获错误... [英] Catch errors in a gridview ...

查看:70
本文介绍了在gridview中捕获错误...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想知道如何在gridview中捕获错误,谢谢!

Hello, I want to know how to catch errors in a gridview, thanks!

推荐答案

如果您尝试执行使用GridView添加新记录的操作,可以处理RowInserted事件处理程序.然后在此事件处理程序中,检查e.Exception属性.如果它不为null,则可以基于exception(Inner Exception)属性采取适当的操作.
类似地,当行分别被更新和删除时,您可以处理RowUpdated和RowsDeleted事件处理程序以处理错误.
If you are trying to perform Adding a new record using GridView, you can handle RowInserted event handler. Then in this event handler check the e.Exception property. If it is not null then you can take appropriate actions based on the exception(Inner Exception) property.
Similary u can handle RowUpdated and RowsDeleted event handlers to handle errors when the Row is updated and deleted respectively.


使用try catch块
例如:
Use try catch block
For Example:
public void BindMyGrid()
{
    try
    {
      //bind grid here with datasource 
            
    }
    catch(Exception ex)
    {
     
    } 
}



我不明白你的意思吗?您想捕捉什么样的错误?
如果与数据绑定有关,则使用try catch块,
请提供有关该问题的适当详细信息,以便更轻松地获得答案
Hi,
I cant get you? what kind of errors you want to catch?
if it is relating to data binding then use try catch block,
please give proper details regarding the the issue so that it will be easier to get answer


这篇关于在gridview中捕获错误...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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