Search code examples
.netlinquser-controlssqldatasourceresponse.write

ASP Recomendation needed: (Linq or SqlDataSource?) + (Response.Write or UserControls or Repeater?


I'm a bid new in ASP.net and developing a website that holds user-friendly list of categorized items and when clicked the details for the items (image gallery, text, contact forms, that kind of stuff, and maybe later user comments and rates). I've read a lot and still can get to a conclusion about my questions, so I need a piece of advise. I need a [good performance+low complexity+not close to be deprecated] recommendations in 2 important things that I'm trying to decide right now.

1) Linq or SqlDataSource? I don't mind writing the SQL for the SqlDataSource, but I've read Linq is the new age so I'm afraid to have an obsolete site in 2 years. Or not paying attention to Linq benefits.

2) I believe I can't use gridview controls for the products paginated lists because they are extremely layout-rigid for the company target customers. The web design of the product lists is kind of youtube video results list. And when clicked displays the hole information about the item (in other page). How should I generate the HTML code for the list of products? I used to concat "html"+readers data (query results) and send them to the page with Response.Write(), but I read that doesn't work with UpdatePanel easily and it's a bit "old technique" what's your position about it?. Then I started to read about repeaters but I believe they won't allow me to approach my model classes as the examples I've seen evaluate directly the query. Finally I starter to read about creating my own controls "ASP users control" that will allow me to keep custom html blocks (styled list items with internal divs) and add some classes properties (the database info), which I hope can generate the list of products in the current layout. Keep in mind that I may be asked for implement ajax paging soon.

Please I need to know the best (recommended) technique to start to learn the details an keep going with the project. thanks a lot.


Solution

  • The GridView is designed for table data. It can be manipulated in the way you're describing, but that's not it's point. The Repeater or ListView would do much better in regards to what you're describing as wanting to do. As a side note, all of these databound controls take an iterator which can be done entirely on the code side (which I typically do) or you can use a DataSource control.

    building a html table in memory and using response write (or even a literal control) will be fast, but you would have to recompile to make any changes to the presentation layer, and as stated does not work with Update Panel.

    That said, I never use the UpdatePanel. I use jquery to post/get data, and then use jquery to make changes that impact the UI.

    In addition to working with server-based solutions, there are CLIENT-side solutions that can be used with asp.net such as the Knockout.js library for building MVC forms.

    Now, as for Linq versus SqlClient that's really a matter of preference, and each has benefits and drawbacks. Linq-to-sql is EASY to use (for most things), but changes to the underlying database must be reflected in the DataContext. On a personal note, I love Linq-to-sql, and use it whenever possible.