I have some basic dropdownlist databinding code. I need to modify the datasource at Runtime and insert a new field.
ddlPrimaryCarrier.DataSource = FinancialInstitutions;
ddlPrimaryCarrier.DataValueField = "EntityCode";
ddlPrimaryCarrier.DataTextField = "EntityNameDesc";
ddlPrimaryCarrier.DataBind();
I actually want to add a field to the collection that is a formatted string of the description and the code. Like...
var newField = string.Format("({0}) - {1}", "EntityCode", "EntityNameDesc");
then
ddlPrimaryCarrier.DataTextField = "newField";
What is the correct way to do this? Can I loop through the exisiting collection and create a new list of anonymous types with the field I need? Anyone have any examples of how to do that?
Thanks, ~ck in San Diego