导出gridview中的错误处理为excel [英] Error handling in export gridview to excel

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

问题描述





我的导出gridview到excel的代码现在工作正常,但是当gridview为空它给出错误,并尝试使用try和catch块但是它没有工作,请提供解决方案来处理此错误。

解决方案

检查 GridView 是否有如下行...

  if (Grid1.Rows.Count  >   0 
{
// 导出到Excel
}
else
{
// 不要导出
}



这里 Grid1 ID GridView


Hi,

My code for export gridview to excel is working fine right now but when gridview is empty its giving error, and tried with try and catch block but its not working so, please provide solution to handle this error.

解决方案

Check if GridView has rows like below...

if(Grid1.Rows.Count > 0)
{
    // Export to Excel
}
else
{
    // Don't Export
}


Here Grid1 is the ID of GridView.


这篇关于导出gridview中的错误处理为excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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