2017-05-26 9 views
0

私は剃刀のビューからコントローラに学生の出席を取得したいと思います。ある行で、ラジオボタンの値にアクセスしたいと思います。そして、多くの行があります。一度にすべての行データにアクセスしてコントローラに送信するにはどうすればよいですか?学生の出席データをフォームからコントローラに取得する

マイカミソリビューは次のとおりです。

<table class="table"> 
         <thead class="thead-inverse"> 
          <tr> 

           <th>Full Name</th> 
           <th>Roll No</th> 
           <th>Status</th> 

           @* <th>Status</th>*@ 
          </tr> 
         </thead> 
         <tbody> 
          @using (@Html.BeginForm("Save", "Attendance", FormMethod.Post, new { @class = "form-horizontal" })) 
          { 

           foreach (var student in Model.Students) 
           { 
            <tr> 
             <td>@student.Name</td> 
             <td>@student.RollNo</td> 
             <td> 

              <div data-toggle="buttons"> 
               <label class="btn btn-success active"> 
                <input type="radio" name="options" id="1" autocomplete="off" checked> Present 
               </label> 
               <label class="btn btn-danger"> 
                <input type="radio" name="options" id="2" autocomplete="off" checked> Absent 
               </label> 
               <label class="btn btn-primary"> 
                <input type="radio" name="options" id="3" autocomplete="off" checked> On Leave 
               </label> 
               <label class="btn btn-warning"> 
                <input type="radio" name="options" id="4" autocomplete="off" checked> Short Leave 
               </label> 
              </div> 
             </td> 
            </tr> 

           } 
           <div class="form-group"> 
            <div class="col-lg-10 col-lg-offset-2"> 
             <button type="submit" class="btn btn-success">Submit</button> 
            </div> 
           </div> 

          } 
         </tbody> 
        </table> 

あなたは私が達成したいものを見ることができるように私は私のウェブページのスクリーンショットを添付しました。

​​

答えて

0

あなたは多分HttpPostに戻っFormCollectionを渡ししようとしている場合はわかりません。ここでは簡単な例です:

[HttpPost] 
    public ActionResult Save(FormCollection form) 
    { 
     //form variable should contain data from form controls. 
     return View(); 
    } 
0

あなたは、コントローラへの学生のリストを渡すことができます。

[HttpPost] 
public ActionResult Save(List<Students> students) 
{ 
    //here you can manipulate that list 
    return View(); 
} 

あなたはすべての生徒を合格ビュー提出していることを確認したり、「すべてを選択」ボタンを作成

関連する問題