Test Multi Check box

CSharp · Mvc

Model

using System;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;

namespace HelloWorldMvcApp
{
	public class ReportsViewModel
	{
		public List<CsReports> Reports { get; set; }
	}
	
	public class CsReports
    {
		public int Id { get; set; }
		public string Name { get; set; }
	}
}

View

@using HelloWorldMvcApp
@model ReportsViewModel


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript">
$(document).ready(function(){
    console.log('mohit');
});
</script>
<div class="row">
    <div class="col-md-8">
        <div>            
            <div>
                <table id="tblReports">
                    <thead>
                        <tr>
                            <th>Report ID</th>
                            <th>Name</th>
                        </tr>
                    </thead>
                    <tbody>

                        @foreach (var report in Model.Reports)
                        {							
                            <tr>
								
                                <td>@report.Id</td>                                
                                <td><a href="#">@report.Name</a></td>
                            </tr>
                        }

                    </tbody>

                </table>
            </div>
        </div>

    </div>

</div>

Controller

using System;
using System.Web.Mvc;
using System.Collections.Generic;

namespace HelloWorldMvcApp
{
	public class HomeController : Controller
	{
		[HttpGet]
		public ActionResult Index()
		{
			return View(new ReportsViewModel()
                {
                    Reports = new List<CsReports>()
                    {
                        new CsReports()
                        {
                            Id = 1,
                            Name = "Report 1"
                        },
                        new CsReports()
                        {
                            Id = 2,
                            Name = "Report 2"
                        },
						new CsReports()
                        {
                            Id = 3,
                            Name = "Report 3"
                        }
                    }
                });
		}		
	}
}
;