[英]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 语句之后编写的代码是不可访问的。
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.