Click here to Skip to main content
15,904,415 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//(this is label name )cnametext.Text = dt.Rows[0]["cname"].ToString();
//(this is label name ) lnotext.Text = dt.Rows[0]["lno"].ToString();
Posted

You can hide like below,

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


Include above lines after your assignment code.
 
Share this answer
 
Comments
Member 12119075 14-Jan-16 1:12am    
how do i check dt.Rows[0]["cname"].ToString(); is null or empty
Sri Nivas (Vasu) 14-Jan-16 1:18am    
You can check like below
if (dt.Rows[0]["cname"] != null && !string.IsNullOrEmpty(dt.Rows[0]["cname"].ToString() ) )
{
// statements for not null
}
Check wheather data is there or not, if data is not there then set the Visible property as false.

cnametext.Visible = false;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900