Click here to Skip to main content
13,291,254 members (61,018 online)
Click here to Skip to main content
Add your own
alternative version


25 bookmarked
Posted 3 Oct 2004

Address Book that shows the physical address

, 3 Oct 2004
Rate this:
Please Sign up or sign in to vote.
This article shows how you can use MapQuest QueryString in your own application.


Have you ever made an address book? What does it have? Addresses, names, emails, and maybe you can also send an email using your address book, right? How cool it would be if you have a list of people in your table with their addresses and when you click on a person's information you can see his physical address. In this article I will show you how easy it is to attach the parameters to the request sent to MapQuest. You can use any type of address finder website you wish to use, I will be using MapQuest in my example.

Making the database

Let's first make a simple database which contains Person ID, Name, and ZIP code. You can use the full address of a person but I have noticed that most of the time services like MapQuest are not able to locate the actual address. I will be using ZIP code for finding the address. Enter some data in the database and we are ready to go!

Displaying Data on the Page

Let's display data on the page by using a DataGrid. All the addresses and ZIP codes you see below are added in your Address Book. Let's assume that your ZIP code is 77304. So we will be finding directions from your ZIP code to the ZIP codes in your address book. Here is how it will look like when you display the DataGrid on the page.

Sample screenshot

Redirecting to MapQuest

I thought about this and could not find a better way to redirect to the directions page. There are several ways that you can perform it like opening the directions page in the new pop up window, or maybe in the frame. I chose a new page (not a pop up) because some browsers have pop up killers so on those browsers the pop up will not open, or in other words the pop up will be killed. Frames also had some problems since some browsers do not support frames. Keeping these reasons in front of me, I chose redirecting the same page to the directions page.

Implementing DataGrid Select Column Code

Time has come to code, so, in the DataGrid's SelectedIndexChanged event, write this code:

private void ChangeSelection(object sender, System.EventArgs e)
    // gets the selected ZipCode from the DataGrid selected row
    string otherZipCode = myDataGrid.SelectedItem.Cells[2].Text;

    // This is the URL in which we are going to embed our parameters.
    string url = "" + 
                 "go=1&do=nw&un=m&2tabval=address&cl=EN" + 
                 "&ct=NA&1tabval=address&1y=US&" + 
                 otherZipCode + "&2ah=&idx=0&" + 
                 "id=4160c6ba-001df-01660-cdbcf364&" + 

    // Redirec to the other page


Yeah, that's all you have to do. I just embedded the variables that contained the values of myZipCode and otherZipCode in the URL, pretty simple right!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
I am the founder of knowledge base website, HighOnCoding, GridViewGuy, and

HighOnCoding is a website which will get you high legally with useful information. There are tons of articles, videos and podcasts hosted on HighOnCoding.

My Blog:


Buy my iPhone app ABC Pop

You may also be interested in...


Comments and Discussions

GeneralSee also Pin
Steven Campbell4-Oct-04 2:23
memberSteven Campbell4-Oct-04 2:23 
GeneralRe: See also Pin
Anonymous5-Oct-04 9:16
sussAnonymous5-Oct-04 9:16 
QuestionWhat about addresses outside the US? Pin
Jos Branders3-Oct-04 23:58
memberJos Branders3-Oct-04 23:58 
AnswerRe: What about addresses outside the US? Pin
azamsharp4-Oct-04 4:07
memberazamsharp4-Oct-04 4:07 
GeneralFormatting of the Article Pin
azamsharp3-Oct-04 20:32
memberazamsharp3-Oct-04 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 3 Oct 2004
Article Copyright 2004 by azamsharp
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid