 |
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
|
|
|
|

May 1st, 2010, 08:38 AM
|
Friend of Wrox
|
|
Join Date: Mar 2010
Posts: 99
Thanks: 21
Thanked 6 Times in 4 Posts
|
|
Visited some page ahead
Hello,
Ive just visited some page ahead in the book. I went to hand-coding data access. Does this technique can apply also on showing data like the GridView ? or it is better to use a control to show data as a table ?
Thanks.
|

May 2nd, 2010, 05:32 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Rushino,
For pure data display, this is pretty easy to do. Just write a LINQ query targeting your Entity Framework, assign it to the DataSource property of the GridView and call DataBind. E.g.:
Code:
var myAlbums = from a in db.Albums
select a;
GridView1.DataSource = myAlbums;
GridView1.DataBind();
When editing data, things get a little more complex. I have a detailed series about doing this here: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=476 However, this is a pretty advanced series and requires good working knowledge of C# and ASP.NET.
Cheers,
Imar
|

May 2nd, 2010, 08:38 AM
|
Friend of Wrox
|
|
Join Date: Mar 2010
Posts: 99
Thanks: 21
Thanked 6 Times in 4 Posts
|
|
Alright, i may get a look into this after ive read your book. This is because i care about performance and in your book you say that using these controls doesnt give you full control over the markup generated and that these controls still generate lots of markup.. so i believe that the best is by hand coding it ? however you provide way for hand coding data insertion in your book.. and this doesnt seem to be hard at all since i already know C#. The same rules may apply to data editing no ?
Waiting your feedbacks.
Thanks.
|

May 2nd, 2010, 08:46 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, it depends.
The DataSource controls don't generate HTML, so using an EntityDataSource or a LINQ query in Code Behind wouldn't make a difference. It's the GridView that generates output in HTML.
However, a GridView is not an easy control to recreate manually. It offers complex features such as paging, sorting, editing, deleting, selection and so on; features that are not easily reproduced with your own code.
If the output in the browser is your main concern, you probably want to use the ListView control instead.
Cheers,
Imar
|

May 2nd, 2010, 05:47 PM
|
Friend of Wrox
|
|
Join Date: Mar 2010
Posts: 99
Thanks: 21
Thanked 6 Times in 4 Posts
|
|
Alright.
So if i understand well.. to show data its better to use a control that show data such gridview or listview because of the features (autogenerated) they offer which increase productivity.. then to insert/update data i could use the hand-coding technique.. (cause i wanna use AJAX and Validation controls in them) ?
But its okay the use the controls or they really affect the performance ?
Just wanna be on the right track.
Thanks for your precious time.
|

May 3rd, 2010, 02:06 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, one way or the other, you need a way to send HTML to the browser.
A GridView or the other controls aren't necessarily bad for performance. In other words, I would not decide not to use a GridView to improve performance. However, like I said in my previous message, if you need *control over the markup*, the GridView may not always be the best option. In that case, look at the ListView.
For data entry pages I find it easier to create my own pages. Again, not related to page performance, but to "developer performance" - productivity.
Cheers,
Imar
|
The Following User Says Thank You to Imar For This Useful Post:
|
|

May 3rd, 2010, 07:00 AM
|
Friend of Wrox
|
|
Join Date: Mar 2010
Posts: 99
Thanks: 21
Thanked 6 Times in 4 Posts
|
|
Alright thanks a lots. Your help is greatly appreciated.
|
|
 |
|