在源代码中检查数据列表是否为空 [英] check datalist empty or not in source code

查看:75
本文介绍了在源代码中检查数据列表是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:
<%if(datalist1!= null)
{%>

一些html

here is my code:
<%if (datalist1 != null)
{ %>

some html

<%}
          else
          { %>


一些html<%}%>

但是在此代码中,如果datalist为空,则不会显示else部分.

请帮帮我.

在此先感谢


some html<%} %>

but in this code the else part are not display if datalist is empty.

Please help me.

thanks in advance

推荐答案

if (DataList1.Items.Count > 0)
{
//put your code here.
}
else
{
//put your code here.
}


我已经做到了:
<%if(datalist1.Items.Count> 0)
{%>
html代码
i have done this:
<%if (datalist1.Items.Count>0)
{ %>
html code
<%}
          else
          { %>
some html<%} %>


这篇关于在源代码中检查数据列表是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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