• How to use DataTable and pass it to list using ViewBag in ASP.NET MVC?

    by  • October 23, 2015 • jQuery and Microsoft .NET, Microsoft .NET Framework, Microsoft ASP.NET MVC, Microsoft Visual Studio .NET • 0 Comments

    Introduction:

    Datatable is used to create to table in the web browser. This plug-in adds much functionality in tables such as filtering, paging, sorting, changing page length, etc. This article shows how DataTable can be integrated and pass it to list using ViewBag into an ASP.NET MVC.

     Model.cs:

    The Model comes to a simple class containing raw data. The fields that we need are ID, Detail, and PersonResp. The source code of the model class is shown below:

    Controller.cs

    Since there is no server-side processing, the controller class is also fairly simple and it practically does nothing. This class only shows how to pass list of string using ViewBag? The controller class used in the example is shown below:

    View.cshtml:

    Add these scripts and style sheet reference in view

     




    Namecheap.com
    Avatar of Abdul Rehman

    About

    Abdul Rehman writes on .NET technologies at GetCodeSnippet.com. GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    http://getcodesnippet.com

    Leave a Reply