Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 15th, 2012, 06:39 PM
Friend of Wrox
Points: 1,905, Level: 17
Points: 1,905, Level: 17 Points: 1,905, Level: 17 Points: 1,905, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default A ringing Endorsement for Wrox! Code from one of your competitor's books

I thought that you might find this interesting but one of your competitors that writes books about .NET had the following code in their book.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
//using System.Web;
//using System.Web.UI;
//using System.Web.UI.WebControls;
using System.Text;

public partial class LINQDefault2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AdventureWorksDataContext dataContext = new AdventureWorksDataContext();
        var employees = from emp in dataContext.Employees
                        where e.Gender == 'F'
                        select emp;
        foreach(var employee in employees)
            Response.Write(employee.EmployeeID + "<br />");
    }
}
It took me a little while (about five minutes) but I figured out why this code was giving me compile errors. I fixed this problem This is bad. See if you want the challenge to fix this code.
There is one thing for certain, these people that wrote this book won't be stealing or taking any money away from you or Wrox anytime soon. Wrox books are the best there is out there in the market, and I give them a very ringing endorsement for their products. My question then becomes how responsive is Wrox to the errata that is submitted by the users of their books?
But my other question is if I wanted to write the output of the employeeId number in the code up above to a Gridview or a Listbox what do you think is the quickest and easiest approach to take?

Thank you once again!
Reply With Quote
The Following User Says Thank You to vbboyd For This Useful Post:
jminatel (March 16th, 2012)
  #2 (permalink)  
Old March 15th, 2012, 06:50 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
See if you want the challenge to fix this code.
e.Gender should be emp.Gender

Quote:
My question then becomes how responsive is Wrox to the errata that is submitted by the users of their books?
In general: pretty good once you get past the errata form that asks a million questions, including your pet name and your **************** size ;-) Kidding aside, the process from Wrox to the author seems pretty quick, but then it depends on the author how long it takes for a reply. For my own books, I've looked at every errata item I've been sent and either confirmed the issue (which then got posted on the Wrox site), or explained why the submitted issue wasn't wrong or incorrect.

Quote:
But my other question is if I wanted to write the output of the employeeId number in the code up above to a Gridview or a Listbox what do you think is the quickest and easiest approach to take?
Assign a Data Source and call DataBind:

Code:
 
myGridView.DataSource = employees;
myGridView.DataBind();
This provides the entire Employee object to the grid, giving you access to all of its other properties. If you only need the ID, you could modify the LINQ query to select an anonymous object with only the employee ID.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!
Reply With Quote
The Following 2 Users Say Thank You to Imar For This Useful Post:
jminatel (March 16th, 2012), vbboyd (March 15th, 2012)
  #3 (permalink)  
Old March 15th, 2012, 06:52 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Haha, I love spam detection. I realize **** size can be anything ;-) In my case, I talked about footwear.... ;-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
vbboyd (March 15th, 2012)
  #4 (permalink)  
Old March 15th, 2012, 07:25 PM
Friend of Wrox
Points: 1,905, Level: 17
Points: 1,905, Level: 17 Points: 1,905, Level: 17 Points: 1,905, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default My real question is...

I am sorry and I guess I should have been more specific. What I was really wondering is it possible to filter the result set that you get back from a data set from LINQ so that say for instance you can load a list box with only the employees that are from Arizona and then filter another group of employees into a different list box that are from Wyoming? Could that be done in the where clause or just exactly is the best way to do this in code so that I can take two different filters one for the employees in Arizona and one for the employees in Wyoming and put their first and last names in separate drop down listboxes for each state?

Thanks once again!
Reply With Quote
  #5 (permalink)  
Old March 16th, 2012, 05:28 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
What I was really wondering is it possible to filter the result set that you get back from a data set from LINQ
Sure....

Code:
 
AdventureWorksDataContext dataContext = new AdventureWorksDataContext();
var employees = from emp in dataContext.Employees
                        where e.Gender == 'F'
                        select emp;
 
var fromArizona = from emp in employees 
                         where e.State == "Arizona"
                          select emp;
 
// Or use:
var fromArizona = employees.Where(e => e.State == "Arizona");
 
var fromWyoming  = from emp in employees 
                              where e.State == "Wyoming"
                              select emp;
 
// Or use:
var fromWyoming = employees.Where(e => e.State == "Wyoming");
All of this assumes that the Employee has a State property... Since it queries the local query employees, these queries return Female employees only.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!

Last edited by Imar; March 16th, 2012 at 05:31 AM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some code samples in WROX books are bad. mangel Forum and Wrox.com Feedback 6 April 1st, 2011 03:05 AM
Wrox Books stu9820 Wrox Book Feedback 3 February 6th, 2004 12:11 PM
Wrox Books Online sivko22 Forum and Wrox.com Feedback 3 December 3rd, 2003 12:34 PM
Wrox Books Online sivko22 BOOK: Beginning ASP.NET 1.0 1 October 11th, 2003 04:33 PM
Old books from WROX sAiNz Pro JSP 0 July 31st, 2003 10:40 PM



All times are GMT -4. The time now is 10:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.