C#: How to fill textbox depending on the value in the database -


i have application search address of customer in database. added 4 textbox namely txtaddr1, txtaddr2, txtaddr3 , txtadd4 display address of customer in database. in database there 6 fields address, these address1, address2, address3, address4, citypostalcode , attentionto. need following:

if field of address(address1, address2, address3, address4, citypostalcode , attentionto) in database not empty. then,

txtaddress1.text = address1 + " " + address2; txtaddress2.text = address3 + " " + address4; txtaddress3.text = citypostalcode; txtaddress4.text = attentionto; 

if address3 , address4 empty,

txtaddress1.text = address1; txtaddress2.text = address2; txtaddress3.text = citypostalcode; txtaddress4.text = attentionto; 

and other scenarios if address3 empty, address1 , address3 empty etc etc.

i know can handle using if...else condition question be, there other way this? or stick in doing if...else condition on every scenarios? thanks.

well can use ternary operator ?: saying

txtaddress1.text = (!string.isnullorempty(address2))                                    ? address1 + " " + address2                                    : address1; 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -