简体   繁体   English

检查 c# 中 DataSet 中的变量值是否为 NULL

[英]Check if variable values are NULL in DataSet in c#

I am trying to iterate through a DataSet to check if the variable Mp.TheObjectPropertyNameMatr of MasterPage has returned NULL values.我正在尝试遍历DataSet以检查 MasterPage 的变量Mp.TheObjectPropertyNameMatr是否已返回NULL值。

When the variable Mp.TheObjectPropertyNameMatr of MasterPage has returned NULL values, I need redirect this aspx page to default aspx page.MasterPage的变量Mp.TheObjectPropertyNameMatr返回NULL值时,我需要将此 aspx 页面重定向到默认 aspx 页面。

But If add on DataSet this code:但如果在DataSet上添加此代码:

private DataSet RetrieveProducts()
{
    if (!String.IsNullOrEmpty(Mp.TheObjectPropertyNameMatr))
    {
        DataTable dt = new DataTable();
        DataSet ds = new DataSet(); 
        ....... 
        return ds;
    }
    else
    {
        return null;
        Response.Redirect("Default.aspx");     
    }
}

I Have this error:我有这个错误:

No executable code没有可执行代码

On this line code:在这一行代码:

Response.Redirect("Default.aspx");  

Please can you help me?请问你能帮我吗?

You are getting error "No executable code" because you are returning null before Response.Redirect("Default.aspx");您收到错误“无可执行代码” ,因为您在Response.Redirect("Default.aspx");之前返回null ; line.线。

In your case, Code written after return statement is not reachable.在您的情况下,在 return 语句之后编写的代码是不可访问的。

From MSDN :来自MSDN

The return statement terminates execution of the method in which it appears and returns control to the calling method. return 语句终止它出现的方法的执行,并将控制权返回给调用方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM