Given the following class....
namespace IMTool.Data
{
public partial class AllContracts
{
internal class Metadata
{
public int ContractId { get; set; }
[Required]
public string Name { get; set; }
}
}
}
and given the following.
using (var context = new IMToolDataContext())
{
ddlContracts.DataValueField = "ContractId";
ddlContracts.DataTextField = "Name";
ddlContracts.DataSource = context
.AllContracts
.OrderBy(o => o.Name);
ddlContracts.DataBind();
}
How can I strongly type the dropdown list DataValue and the DataText fields? Basically I do not want to use a string but rather the column name from the entity, I am using LinqToSql (well PLinqo which is a codesmith set of templates to generate my datalayer) Can anyone help?