Wrox Programmer Forums
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 18th, 2014, 02:28 PM
Authorized User
Join Date: Dec 2010
Posts: 27
Thanks: 10
Thanked 0 Times in 0 Posts
Default SqlDataSource vs EntityDataSource

Hi, there.

Currently, I am building a site, relying heavily on the Beginning ASP.NET 4 book.
As far as I can see, one can choose to work with either SqlDataSources or EntityDataSources. Both are used in the book and, if I am correct, which way you go is mainly a matter of choice. Everytning you can do with a SqlDataSource can be done with a EntityDataSource and vice versa. Am I right?

In chapter 13 of the book, SqlDataSources are used in connection with DataGridView and DetailsView. Then, in chapter 14, EntityDataSources are used for GridView, Repeater an ListView controls. Is there a particular reason for this choice of data source type other than introducing the reader to LINQ and the ADO.NET Entity Framework?
Gudni G. Sigurdsson
Old March 18th, 2014, 03:06 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Both have their pros and their cons. The SqlDataSource is easy to set up, but harder to maintain. If you rename tables or columns, you won't notice your SQL is broken until you run the page.
The EntityDataSource is, at first, harder to set up and configure, but then provides better (but not perfect) type checking.

However, the EntitDataSource control is now considered obsolete. Instead, you're advised to use Model Binding: http://blogs.msdn.com/b/webdev/archi...web-forms.aspx

This requires a more recent version of .NET / Visual Studio than this book targets but if you happen to use VS 2012 or later, this is the way forward.


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
Gudni (March 19th, 2014)
Old March 19th, 2014, 04:18 AM
Authorized User
Join Date: Dec 2010
Posts: 27
Thanks: 10
Thanked 0 Times in 0 Posts

Thank you, Imar.
Being a relatively inexperienced web developer, I am learning many new things at the same time. But I will certainly have a look at Model Binding. The site I mention in my post, is done with VS 2010, but I have recently installed VS 2013 and will inspect MB in due time.
Gudni G. Sigurdsson

Similar Threads
Thread Thread Starter Forum Replies Last Post
CH 14 A Simple EntityDataSource Application - Error! leeWozyWarren BOOK: Beginning ASP.NET 4 : in C# and VB 5 December 7th, 2011 02:28 PM
EntityDataSource Try it Out Exercise Page 497 bimalk BOOK: Beginning ASP.NET 4 : in C# and VB 6 December 5th, 2011 01:27 PM
Update multiple tables with EntityDataSource alharlow ASP.NET 4 General Discussion 3 March 31st, 2011 03:15 AM
Error with EntityDataSource TeaDrinkingGeek BOOK: Beginning ASP.NET 4 : in C# and VB 3 March 20th, 2011 01:54 PM
Questions about EntityDataSource and dynamic binding Rushino ASP.NET 4 General Discussion 4 November 22nd, 2010 09:58 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.