How can I get a GridDropDownList to work with entity framework. Specifically how can I attach a field to the DataTextField property and another field to the DataValueField property? Please see the example below.
Thanks in advance.
Jorge
protected
void
rgDPR_ItemDataBound(
object
sender, GridItemEventArgs e)
{
DbSet<SICCode> sicCodes = DB.SICCodes;
var query = (from codes
in
sicCodes
orderby codes.Industry ascending
select codes.Industry, codes.ID).ToList();
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editedItem = e.Item
as
GridEditableItem;
GridEditManager editMan = editedItem.EditManager;
GridDropDownListColumnEditor editor = editMan.GetColumnEditor(
"SICCodeOverride"
)
as
GridDropDownListColumnEditor;
editor.DataSource = query;
editor.DataTextField =
""
;
// codes.Industry should go here
editor.DataValueField =
""
;
// codes.ID should go here
editor.DataBind();
}
}
Thanks in advance.
Jorge