The Census Bureau does not ask U.S. residents for their immigration status when they are counted in the 2010 Census or other population surveys. A major reason is that bureau officials fear it would make people reluctant to respond, despite the promise that their information is confidential.
So when numbers are cited for the size or characteristics of the undocumented immigrant population, they are estimates that are arrived at indirectly. The Wall Street Journal recently published an interesting article and a blog posting explaining the ins and outs of these estimates. Among the estimates discussed are those produced by the Pew Hispanic Center, including a 2009 report that featured estimates for states.