Paging in ASP.NET MVC part 2


Hi, again this is Part 2 from Paging in ASP.NET MVC.

In Part 1, I showed you how to add all data required.

Now let's try to finish what we start together.

Now will try to add new Controller and Call it StudentController.

The most important one is, what I highlight it (Yellow).

First one is declared our Interface,

  private readonly IStudent repositoryStudent;

building contractor.

 public StudentController(IStudent repoStudent)
            repositoryStudent = repoStudent;


This one our main job :)

ActionResult Index,

First int? page=1, this for your request, when it will be null, the default page will be first one page=1.

next step is reading data from our Repository.

  var model = repositoryStudent.GetStudent;

if no page was specified in the query string, default to the first page (1)

  var pageNumber = page ?? 1; 

 will only contain 25 products max because of the pageSize

  var onePageOfProducts = products.ToPagedList(pageNumber, 25); 

Don't forget to call X.PagedList .

using X.PagedList;

Now to our HTML code.

Just generate Index view.

next Photo will show you what you will have new change.

Again same what we call in our controller, we should call 2 library from X.PagedList.

@using X.PagedList.Mvc;  
@using X.PagedList;

after that to have a good style you need to add,

<link href="/Content/PagedList.css" rel="stylesheet" type="text/css" />

so after all that the most important part is.

@Html.PagedListPager((IPagedList)Model, page => Url.Action("Index", new { page }))


The result will be same next photo.




Youtube Video.....


Hope this article is helpful.

If you have any question, just write in the comment.


Paging in ASP.NET MVC part 1



Today I'm going to write about Paging in ASP.NET MVC.

First, if someone asks you about paging, why?

Sometimes, we have too many rows, Photos, articles and Products you don't want to display all of them in same time,

or let's say, you don't want load 100K row in one click, this will be a big issue with your application.

  So, the solution will be is paging.

and don't forget to use IQueryable rather than List or IEnumerable.

Now, To work our first step is to create new ASP.NET MVC Project.

Follow the Photos.


Choose MVC,


Next Step, Add X.PagedList  From NuGet packages.

So, Now we need data to send it to our HTML page and display it in the table.

First, we need to create new Class in Models folder and call it Student.


Next Step, Create Folder Call it Services will put inside it,

a new class (IStudent class).



After Create our Interface, we need to create Repository Folder with StudentRepository class.

In StudentRepository Class, I have fake data just to show you how it will be in our HTML page.

sure you can Use data from your SQL Server database, using Entry Framework.



Android Application With SQL Server using Web Service Part 3


Welcome again, with Android SQL Server Web Service Connection.

In the last Article we stopped with many errors, I know that, don't worry again.

its just because of SOAP package, you need to include it to your project.

Just Change your Android Studio to Project and go to 

Your Application Name >App >Libs.... 

Just past SOAP package to this path.

after again page to Android.

Until now still you have same errors still, you need to add SOAP package to your Gradle

Gradle Scripts >build.gradle(Module: app)

just add this line(there is one more way to add but use this for now) :

compile files('libs/ksoap2.jar') 

The last thing you need to do is, add this code to Main Activity.



Now, We can say you can run your App.

Be happy,

 if you find any error just post it on the comment or text me to my facebook page.


Source Code: you can find it, in my GitHub Account.

Youtube Video on My Channel.




Android Application With SQL Server using Web Service Part 2


Hi, again to our second part from Android SQL server Web Service.    

After Create 2 Activities Home and log in.

will work on Login because it's our main jobs .

The design will look like this Photo :

I'm sure 100% you can do better than my design ;).

Code in XML .

Don't worry, if you can't copy the code. 

it's on My GitHub Account or First part from this tutorial. 

Eazy and simple till now.

Next Step, not that simple, in your Login Java Class. 

You need to declare and link your layout Component to you Java Code.

Same as this  Photo.

Now, 100% you will get errors in your code, because of  MyAsyncTask() Class, does not Exist, so declare it like this ,

private class MyAsyncTask extends AsyncTask<String,Void,String>
protected String doInBackground(String... strings) {}
protected void onPostExecute(String result) {}

 In the doInBackground method, will be the connection or create Connection String to your Database.

Add this code to :

protected void onPostExecute(String result) {}


part 3

Android Application With SQL Server using Web Service Part 1



In this Article will talk about SQL Server, how to connect to SQL Server Live Database.

but this time will not .NET or Microsoft Tools to read or write andy data from our database.

Today will be Android Application.

will use Android Studio 2.3.3 or Higher for this Application.

So, how to connect to SQL database, its very simple not simple same as, .NET

maybe SOAP package will make it easy. 

Our Project will be Login  Application.

will content 2 parts :

1- ASP.NET Web Service.

  Youtube Link  GitHub Project . 

In this article, I'm not going to talk about Web Service.

2- Android Application, How to Login with Email and Password with Live SQL Database. 

 Youtube Link    GitHub Project 1 .  GitHub 2

Will have  2 Activities and Layouts. 

1- Main Activity or Home Activity this will be opened if the result of login True.

2* Login Activity, this one will have 2 EditText for Email and Password,

and sure one Button For Sign In. 

Let's Start our Android Application with creating a new project.

New Project

- Choose a name for your project.

-  Will Generate New Empty Activity and Layout.

So, this one will Be Home Activity as I mention it will open if the Email and Password True.

You can create any Text View and write in it Welcome or Hello World :).

-Let's create one more Activity and call it Login Activity, this will be for the main job.



part 2