08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 5 ■ <strong>ASP</strong>.<strong>NET</strong> WEB SERVICES 119<br />

addr.City = row.City;<br />

addr.PostalCode = row.PostalCode;<br />

// Add to the list<br />

addrs.Add(addr);<br />

} // foreach<br />

}<br />

return addrs;<br />

This cycles through each row in the data table <strong>and</strong> creates an instance of the Address<br />

class with the data from that row. It then adds this instance to the list of addresses. Once<br />

the loop is complete (i.e., when you’ve iterated through each row), the list is returned to<br />

the caller.<br />

Figure 5-11 shows the results of running this web method in its test page.<br />

Figure 5-11. Running the GetAddresses web method in the test page

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!