Trying to use DataTables with Paging done from SQLServer

Trying to use DataTables with Paging done from SQLServer

moh1234moh1234 Posts: 8Questions: 0Answers: 0
edited February 2014 in General
Firstly thank you for this awesome plugin. I am currently building in ASP.net MVC3 C#.

I need your help or if you can direct me in the right direction:

I am currently populating my table using SQL Server - I fetch ALL the data from the table which can be approx 500k rows which is a very slow process (takes forever). What I want to achieve is todo paging from the sql server i.e. only fetch 2000 rows at a time from the database.

The paging currently done with Datatables is client side but can i change this to use server side for example when next page is clicked it should load the next 2000 rows preferably using Ajax from the database. I also want to keep the sorting options enabled on the client side while achieving the above.

I have seen/read the discussion on "serverside processing for asp.net c# with sql server" but this is with traditional asp.net not mvc. Are there any examples with MVC to what i want to achieve ???

Current code I have, my MVC View page:

[code] @model System.Data.DataTable

$('#myDataTable').dataTable({

});





@foreach (System.Data.DataColumn column in Model.Columns)
{
@column.ColumnName
}



@foreach (System.Data.DataRow row in Model.Rows)
{

@foreach (System.Data.DataColumn column in Model.Columns)
{
@row[column].ToString()
}

}

[/code]
This discussion has been closed.