Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the code is given below

C#
if(result.Count>0)
           {

             foreach(var a in result)
             {
                 txttag.TextBoxValue = a.CompanyName;
             }
    
       }



the result contains two items,comapny name got the last comapny name

What I have tried:

append the companyname to text box
Posted
Updated 17-Mar-16 20:40pm
v3

Hi! your code seems fine. just try this one.

C#
    if(result.Count>0)
    {
      foreach(var a in result)
      {
          txttag.TextBoxValue += a.CompanyName +"\n";
      }

}



you will have new line after each new company added.
this can be helpful.
Thanks.
 
Share this answer
 
v2
you can do some this like given below


if(result.Count>0)
{
StringBuilder strresult = new StringBuilder();

foreach(var a in result)
{
strresult.Append(a.CompanyName)

}
txttag.TextBoxValue = strresult.ToString();

}
 
Share this answer
 
Comments
Stark117 18-Mar-16 2:42am    
Hi! i think its required to have "\n". otherwise string would not be in readable form.
for ex : company1company2company3 would be like this. what say?
Member 12003400 18-Mar-16 2:57am    
Yes formatting can be done anytime as per requirements.

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