Q:

ASP.NET MVC 5 Html.EditorFor and property of type object

I am creating a dynamic user control in MVC 5 application. My view model looks like this:
public class StoredProceduerParametersRecordViewModel
{
    public string ProcedureName { get; set; }
    public string ParameterName { get; set; }
    public string ServerName { get; set; }
    public object ParameterValue { get; set; }
    //public object NewParameterName { get; set; }
}

The NewParameterName could be an int, string, bool or any data type.
I am getting the NewParameterName values from Stored Procedure Parameters
List<StoredProcedureParameter> parameters = new List<StoredProcedureParameter>();
parameters = database.StoredProcedures[procedure.ProcedureName]
                     .Parameters.OfType<StoredProcedureParameter>()
                     .ToList();

foreach (var param in parameters)
{
    StoredProceduerParametersRecordViewModel obj_parameter =
    new StoredProceduerParametersRecordViewModel();

    obj_parameter.ParameterName = param.Name;
    obj_parameter.NewParameterName = CommonHelper.ConvertSmoToClsType(param.DataType.SqlDataType, string.Empty);
    stored_procedure_parameters_list.Add(obj_parameter);
 }

My CommonHelper.ConvertSmoToClsType looks like this:
public static object ConvertSmoToClsType(SqlDataType dataType, string currentValue)
{
   object Object = new object();

   switch (dataType)
   {
       case SqlDataType.BigInt:
       Object = (String.IsNullOrEmpty(currentValue)) ? (Int64)0 : Int64.Parse(currentValue);
       break;
       case SqlDataType.Bit:
       Object = (String.IsNullOrEmpty(currentValue)) ? (Boolean)false : Boolean.Parse(currentValue);
       break;
       case SqlDataType.Char:
       case SqlDataType.VarChar:
       case SqlDataType.VarCharMax:
       Object = (String.IsNullOrEmpty(currentValue)) ? String.Empty : currentValue;
       break;
       case SqlDataType.Real:
       case SqlDataType.Numeric:
       case SqlDataType.Float:
       Object = (String.IsNullOrEmpty(currentValue)) ? 0D : Double.Parse(currentValue);
       break;
       and so on...
    }
}

I am trying to use HTML.Editor to display user controls
@foreach (var obj in Model.List_StoredProceduresParametersRecords_ViewModel)
{
  <tr id="@obj.ParameterName">
      <td class="parameterName" data-value="@obj.ParameterName">@obj.ParameterName</td>
      <td>@Html.Editor("NewParameterName")</td>
  </tr>
}

I referenced my code using this link ---> ASP.NET MVC3 Html.EditorFor and property of type object
However, this solutions is not applicable for list.
How can I show the controls using Html.Editor or Html.EditorFor in my foreach loop?

A:

The EditorFor cannot ready empty strings so what I did was change this line of code.
Object = (String.IsNullOrEmpty(currentValue)) ? String.Empty : currentValue;

TO
Object = (String.IsNullOrEmpty(currentValue)) ? " " : currentValue;

I also changed my code from
<td>@Html.Editor("NewParameterName")</td>

TO
<td>@Html.EditorFor(model => obj.ParameterValue)</td>

It works now, except for my Double object. Do you have any ideas?

