Maybe because I'm new to ASP.Net I find working on .aspx pages very complex and am tempted to move as much code as possible into the C# files. For example I have a small application with a
GridView and DataSource controls all generated by using the wizards on the design pages in Visual Studio 2010.
Would it be considered good practice to move this into the C# code or should I just learn to live with it.
ultimately i dont ever use DataSource controls for my gridviews or any datacontrols. i tend to keep these all in the code behind files, for the aspx pages, or in .cs files. a good practice, since you're starting off, is to get into Entity Framework. it's
very simple to use and to set up. here's a link for getting started:
this guy has a lot of tutorials for EF (i believe 6 in all), and are extremely detailed and helpful.
instead of using datasource controls, you can manipulate which data you want to show, hide, update, insert and delete easily, then bind your datasource in codebehind to your data controls.
a good language to go along w/ Entity framework and your data controls is Linq. if you aren't familiar with Linq, i highly advise that you get comfortable w/ it, as it's extremely powerful. good luck to you.
Pro LINQ: Language Integrated Query in C# 2008
By: Joseph C. Rattz Jr.
Publisher: Apress
Pub. Date: November 2007
Print ISBN: 978-1-59059-789-7
Web ISBN: 1-59059-789-3
asp.net
Please post your code for us to help!!
Mark Answered if it helps - Good luck!
Cheers!
Design And Align - Rob
Marked as answer by digbydog on Nov 23, 2011 02:11 PM
digbydog
Member
11 Points
11 Posts
When to use .aspx files and when to use .CS files?
Nov 23, 2011 02:01 PM|LINK
Maybe because I'm new to ASP.Net I find working on .aspx pages very complex and am tempted to move as much code as possible into the C# files. For example I have a small application with a GridView and DataSource controls all generated by using the wizards on the design pages in Visual Studio 2010.
Would it be considered good practice to move this into the C# code or should I just learn to live with it.
Thank you
asp.net
robwscott
Star
8079 Points
1491 Posts
Re: When to use .aspx files and when to use .CS files?
Nov 23, 2011 02:08 PM|LINK
ultimately i dont ever use DataSource controls for my gridviews or any datacontrols. i tend to keep these all in the code behind files, for the aspx pages, or in .cs files. a good practice, since you're starting off, is to get into Entity Framework. it's very simple to use and to set up. here's a link for getting started:
http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
this is the "code first" method. the following link is the opposite (making your DB first).
http://www.youtube.com/watch?v=BS6IKdUd2V8&feature=related
this guy has a lot of tutorials for EF (i believe 6 in all), and are extremely detailed and helpful.
instead of using datasource controls, you can manipulate which data you want to show, hide, update, insert and delete easily, then bind your datasource in codebehind to your data controls.
a good language to go along w/ Entity framework and your data controls is Linq. if you aren't familiar with Linq, i highly advise that you get comfortable w/ it, as it's extremely powerful. good luck to you.
Pro LINQ: Language Integrated Query in C# 2008
By: Joseph C. Rattz Jr.
Publisher: Apress
Pub. Date: November 2007
Print ISBN: 978-1-59059-789-7
Web ISBN: 1-59059-789-3
asp.net
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
digbydog
Member
11 Points
11 Posts
Re: When to use .aspx files and when to use .CS files?
Nov 23, 2011 02:11 PM|LINK
Thanks for that quick and detailed response.