在asp.net 5控制器操作中迭代多个输入数组表单值 @{ 对于(inti=0;i

在asp.net 5控制器操作中迭代多个输入数组表单值 @{ 对于(inti=0;i,asp.net,Asp.net,在模型中使用数组或列表,例如:list mondayM{get;set;} 在您的视图中,将id=“mondayM”更改为id=“mondayM[@i]” 希望此示例将有助于: <div class="form-group"> @{ for (int i = 0; i <= 7; i++) { <input id="mondayM" name="StartTime[]" type="text" class="time monda

在模型中使用数组或列表,例如:list mondayM{get;set;} 在您的视图中,将id=“mondayM”更改为id=“mondayM[@i]”

希望此示例将有助于:

<div class="form-group">
@{
  for (int i = 0; i <= 7; i++)
    { 
      <input id="mondayM" name="StartTime[]" 

       type="text" class="time monday M" />

    }
}
</div>
//模型
公共类博士课程表
{
公共字符串Something{get;set;}
}
公共类DoctorScheduleModel
{
公共IList DoctorSchedules{get;set;}
公共DoctorScheduleModel()
{
DoctorSchedules=新列表();
对于(int i=0;i<7;i++)
{
添加(新的DoctorSchedule());
} 
}
}
//控制器
公共类DoctorScheduleController:控制器
{
公共行动结果索引(DoctorScheduleModel模型)
{
foreach(模型中的DoctorSchedule DoctorSchedule.DoctorSchedules)
{
var x=医生日程安排;
}
}
}
//看法
@模型DoctorScheduleModel
@对于(int i=0;iModel.DoctorSchedules[i].Something)
@}

在模型中使用数组或列表,例如:list mondayM{get;set;} 在您的视图中,将id=“mondayM”更改为id=“mondayM[@i]”

希望此示例将有助于:

<div class="form-group">
@{
  for (int i = 0; i <= 7; i++)
    { 
      <input id="mondayM" name="StartTime[]" 

       type="text" class="time monday M" />

    }
}
</div>
//模型
公共类博士课程表
{
公共字符串Something{get;set;}
}
公共类DoctorScheduleModel
{
公共IList DoctorSchedules{get;set;}
公共DoctorScheduleModel()
{
DoctorSchedules=新列表();
对于(int i=0;i<7;i++)
{
添加(新的DoctorSchedule());
} 
}
}
//控制器
公共类DoctorScheduleController:控制器
{
公共行动结果索引(DoctorScheduleModel模型)
{
foreach(模型中的DoctorSchedule DoctorSchedule.DoctorSchedules)
{
var x=医生日程安排;
}
}
}
//看法
@模型DoctorScheduleModel
@对于(int i=0;iModel.DoctorSchedules[i].Something)
@}

您在控制器中使用的是模型还是formcollection?请告诉我如何在控制器操作中以“public ActionResult BusinessTiming(ICollection ds){}的形式进行迭代。这里有DoctorSchedule是我的模型类。我使用的是模型类(DoctorSchedule)。我还使用了数组属性{get,set}您是否在控制器中使用模型或formcollection?请告诉我如何在控制器操作中以“public ActionResult BusinessTiming(ICollection ds){}”的形式进行迭代。DoctorSchedule是我的模型类。我正在使用模型类(DoctorSchedule)。我还使用了数组属性{get,set}请告诉我如何在控制器操作中以“public ActionResult BusinessTiming(ICollection ds){}”的形式迭代。DoctorSchedule是我的模型类。在控制器中使用foreach循环。当我写入字符串[]时,错误是“无法隐式地从字符串转换为字符串[]”mondayM=modelobject.mondayM;您能告诉我迭代代码(foreachloop和代码元素)吗?感谢uI在模型中添加了一个循环,用7个计划初始化列表。控制器中的代码将迭代列表中的所有项目。请告诉我如何在控制器操作中迭代“public ActionResult BusinessTiming(ICollection ds){}”。DoctorSchedule是我的模型类。在控制器中使用foreach循环。当我编写string[]mondayM=modelobject.mondayM时,错误是“无法隐式地从string转换为string[]”;您能告诉我迭代代码(foreachloop和代码元素)吗。感谢用户界面向模型添加了一个循环,用7个计划初始化列表。控制器中的代码将迭代列表中的所有项目。