Better to fetch data with a web service or directly from a database in .net
Ok, if you have no reason to use a web service, then no. It's always best to remove unneeded layers if you can and go straight against the DB (via a separate class library, of course) if you can. There really is no reason to use a web service just for the sake of using it.
A web service is useful if you intend to distribute code between servers for better scalability. But if everything runs on the same server, there won't be much of the added complexity associated with the web service. If you want to stack your code, you can just as easily create a class library for DB code.
a source to share
Using adding a web service and an extra step as the web service will eventually need to connect to the database to fetch the data. Using a web service is a trade-off. You end up sacrificing some speed for an extra abstraction between the UI and the database.
A web service adds a layer of abstraction between the database and the website. The website won't know directly what's going on in the data layer, allowing the web service layer to transform the data and apply business logic that doesn't need to worry about the website (or UI layer). If you plan to have complex logic needed by multiple applications, web services can help because all applications can connect to it and it applies the necessary rules and transformations to the data.
a source to share
Chances are, none of your options are the best.
I've always avoided accessing the database directly from code. Outline your database logic so that you have a level of separation between the consuming code (your code behind) and the code responsible for actually getting your data.
Having said that, using a web service as that abstraction makes sense sometimes. Web services typically require data to be serialized for every call and are expensive for this (and other) reasons. If you don't need a web service (for example, to allow access through HTTP proxies and firewalls), think twice about this apporach.
Without understanding your use case, it might make more sense to have separate data logic (in a separate assembly, for example), but not behind the web service. You should investigate creating a "domain model" of C # objects, and the database abstraction returns them, not return connection / data readers. You can also look at other tools like Object Relational Mappers (like NHibernate) that can get a lot of the hard work out of this work.
a source to share
This is an architectural decision and depends on what kind of application you are building, how it is deployed, etc.
It is generally good design, regardless of web service usage, for separation using a model such as data, business logic, and presentation layers.
Regarding web services, if, for example, your deployment is on multiple servers, and data access and business logic are separate from the presentation, and the presentation is possibly a public user interface, and you might want to put web pages in it A UI on a server that is protected by a firewall from basic business logic and data layers (for security reasons). For this, it may be easier to expose the interface to the UI layer as a web service.
You might also want to expose your business logic to other consumers as an API to use them, and a web service would be perfect here. If your user interface was later handled by a third party, it might be worth using a web service to expose the business logic interface while protecting the implementation. The web service also allows your user interface to be language independent.
However, this should not be the case. You can expose an interface between business logic and a user interface that is not a web service. Maybe you are just deploying everything to one server, or some kind of internal deployment that doesn't need a web service, and just decide that you have a call to the asp code right into the business logic / data access assembly.
However, regardless of web services, it's best not to just inject data access code or business logic directly into your UI code. It ties your UI to implementation specifics and makes it difficult to separate if you want to replace the UI in the future.
a source to share