当标签没有从数据库从Sql显示时,如何隐藏我的标签 [英] How Do I Hide My Label , When That Label Have Nothing To Display From Datbase From Sql

查看:73
本文介绍了当标签没有从数据库从Sql显示时,如何隐藏我的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//(这是标签名称)cnametext.Text = dt.Rows [0] [cname]。ToString();

//(这是标签名称)lnotext.Text = dt.Rows [0] [lno]。ToString();

//(this is label name )cnametext.Text = dt.Rows[0]["cname"].ToString();
//(this is label name ) lnotext.Text = dt.Rows[0]["lno"].ToString();

推荐答案

你可以像下面一样隐藏,



You can hide like below,

cnametext.Visible =  ! string.IsNullOrEmpty(cnametext.Text )
lnotext.Visible =  ! string.IsNullOrEmpty(lnotext.Text )





在作业代码后面加上以上行。



Include above lines after your assignment code.


检查是否存在数据,如果数据不存在,则将Visible属性设置为false。



cnametext.Visible = false;
Check wheather data is there or not, if data is not there then set the Visible property as false.

cnametext.Visible = false;


这篇关于当标签没有从数据库从Sql显示时,如何隐藏我的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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