I have
public class ListA
{
private string code;
private string name;
public string Code { get { return code; } set { code = value; } }
public string Name { get { return name; } set { name = value; } }
}
List<ListA> lst = new List<ListA>();
public List<ListA> getList()
{
lst.Add(new ListA { Code = "ABC", Name = "Smith" });
lst.Add(new ListA { Code = "XYZ", Name = "Abbey" });
return lst;
}
and in the dropdownlist I want ABC:Smith populated.
ddlList.DataTextField = "Name";
only populates the name.
I want to populate both name and code. How do I do that. Please help.