Click here to Skip to main content
16,014,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am binding persons name to dropdownlist from database but i need to show there address also in dropdown please provide some solution
Posted
Comments
DamithSL 4-Jun-14 0:25am    
how you bind data? update question with your code and SQL testaments

C#
var Company = from com in objJobDAO.GetAllCompany()
                             where com.Status = true && strCompanyIDs.Contains(com.CompanyID.ToString())
                             select new
                             {
                                 com.CompanyID,
                                 PersonInfo = com.name + " ; " + com.address 

                             };

               rddlJobCompanyJS.Items.Clear();
               rddlJobCompanyJS.DataSource = Company;
               rddlJobCompanyJS.DataTextField = "PersonInfo";
               rddlJobCompanyJS.DataValueField = "CompanyID";
               rddlJobCompanyJS.DataBind();
 
Share this answer
 
You may have SQL statement as below
SQL
select Name from YourTable 

change it to
SQL
select Name + '-'+ Address as NameAddress from YourTable 

then you can bind with NameAddress
 
Share this answer
 
Comments
Member 10252940 4-Jun-14 5:11am    
i have my data in list filled from BE and lst.Name and lst.Adress
now i want to show in both of them in dropdownlist with line break so i m trying to do like this but not working
ddlselect.Datatextfeiild=lst.Name+"\n"+lst.adress;
ddlselect.datavaluefeild=lst.Personid;
which gives me an error of lst.Name not an property of be object

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