locked
Dynamic Data Futures Enumerator_Edit FieldTemplate with Entity Framwork RRS feed

  • Question

  • User-330204900 posted

    I realise this is an issue with the Entity Framework in that you cannot set the type on any property. But is there any work around that will allow this other than writing specific FieldTemplates?

    I tried the only Enum workaround wich is to create a custom property but custom properties are not supported; you get a "NullReferenceException: Object reference not set to an instance of an object." error if you try to use this method [:(]

    I did read David Ebbo mention that this was an issue with the EntityDataSource and that it was going to be looked into to see if there was a fix, is there any progress on this?

    Server Error in '/DD_EF_DBPermissions' Application.


    Type provided must be an Enum.

    Parameter name: enumType

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: Type provided must be an Enum.
    Parameter name: enumType

    Source Error:

    Line 24: 		{
    Line 25: 			DropDownList1.Items.Add(new ListItem("[Not Set]", String.Empty));
    Line 26: 			foreach (string name in Enum.GetNames(Column.ColumnType))
    Line 27: 			{
    Line 28: 				DropDownList1.Items.Add(new ListItem(name));

    Source File: e:\My Local Documents\Visual Studio 2008\Websites\DD_EF_DBPermissions\DynamicData\FieldTemplates\Enumeration_Edit.ascx.cs    Line: 26

    Stack Trace:

    [ArgumentException: Type provided must be an Enum.
    Parameter name: enumType]
       System.Enum.GetNames(Type enumType) +7530942
       Enumeration_EditField.Page_Load(Object sender, EventArgs e) in e:\My Local Documents\Visual Studio 2008\Websites\DD_EF_DBPermissions\DynamicData\FieldTemplates\Enumeration_Edit.ascx.cs:26
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.LoadRecursive() +141
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +265
       System.Web.UI.ControlCollection.Add(Control child) +80
       System.Web.UI.WebControls.CellControlCollection.Add(Control child) +43
       System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +33
       System.Web.UI.WebControls.CellControlCollection.AddAt(Int32 index, Control child) +48
       System.Web.UI.WebControls.TableCellCollection.AddAt(Int32 index, TableCell cell) +30
       System.Web.UI.WebControls.TableCellCollection.Add(TableCell cell) +16
       System.Web.UI.WebControls.DetailsView.InitializeRow(DetailsViewRow row, DataControlField field) +430
       System.Web.UI.WebControls.DetailsView.CreateDataRowsFromFields(Object dataItem, Boolean dataBinding, TableRowCollection rows) +393
       System.Web.UI.WebControls.DetailsView.CreateDataRows(Boolean dataBinding, TableRowCollection rows, Object dataItem) +46
       System.Web.UI.WebControls.DetailsView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1186
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
       System.Web.UI.WebControls.DetailsView.PerformDataBinding(IEnumerable data) +12
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
       System.Web.UI.WebControls.DetailsView.DataBind() +4
       System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
       System.Web.UI.WebControls.DetailsView.EnsureDataBound() +184
       System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 <!-- [ArgumentException]: Type provided must be an Enum. Parameter name: enumType at System.Enum.GetNames(Type enumType) at Enumeration_EditField.Page_Load(Object sender, EventArgs e) in e:\My Local Documents\Visual Studio 2008\Websites\DD_EF_DBPermissions\DynamicData\FieldTemplates\Enumeration_Edit.ascx.cs:line 26 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at System.Web.UI.WebControls.TableRow.CellControlCollection.Add(Control child) at System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) at System.Web.UI.WebControls.TableRow.CellControlCollection.AddAt(Int32 index, Control child) at System.Web.UI.WebControls.TableCellCollection.AddAt(Int32 index, TableCell cell) at System.Web.UI.WebControls.TableCellCollection.Add(TableCell cell) at System.Web.UI.WebControls.DetailsView.InitializeRow(DetailsViewRow row, DataControlField field) at System.Web.UI.WebControls.DetailsView.CreateDataRowsFromFields(Object dataItem, Boolean dataBinding, TableRowCollection rows) at System.Web.UI.WebControls.DetailsView.CreateDataRows(Boolean dataBinding, TableRowCollection rows, Object dataItem) at System.Web.UI.WebControls.DetailsView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.DetailsView.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) at System.Web.UI.WebControls.DataBoundControl.PerformSelect() at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at System.Web.UI.WebControls.DetailsView.DataBind() at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() at System.Web.UI.WebControls.DetailsView.EnsureDataBound() at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.dynamicdata_pagetemplates_insert_aspx.ProcessRequest(HttpContext context) in c:\Users\Stephen J. Naughton\AppData\Local\Temp\Temporary ASP.NET Files\dd_ef_dbpermissions\ccf60f39\9279a92\App_Web_isidjdl7.0.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -->

    Monday, October 27, 2008 12:25 PM

All replies

  • User1641955678 posted

    Hi Steve,

    I may  be misunderstanding what you're trying to do, but have you tried using the EnumDataTypeAttribute (from the futures)?  The idea is that you can have a column of type integer, and then add this attribute to set a specific enum type for it. e.g.

    [EnumDataType(typeof(YourEnumType))]
    public int SomeField {get; set;}

    thanks,
    David

    Monday, October 27, 2008 2:28 PM
  • User1641955678 posted

    Looking at the code in your error message, it doesn't seem to match what's in the 07/16 Futures app.  Could it be that you have an older (or otherwise different) copy of the enum field template?

    David

    Monday, October 27, 2008 2:34 PM
  • User-330204900 posted

    I'll grab everything fresh and see what happens my enum may be from a previous build as I'l converting my permissions based system to EF [:D]

    Monday, October 27, 2008 4:01 PM