I have a table that has information of fire departments around the state. I am trying to set up the gridview so that the address is a hyperlink with google maps. For example, In my address column, I have an address such as 745 W Colfax Ave Denver CO 80204, I want to change it so the DataNavigateUrlFormatString would read "https://maps.google.com/maps?q=" + the address with the spaces replaced with a '+' symbol so it would end up being like this 745 W Colfax Ave Denver CO 80204. Here's my ASP.Net code snippet:

    <asp:BoundField DataField="resource" HeaderText="Resource" />
    <asp:BoundField DataField="name" HeaderText="Name" />
    <asp:BoundField DataField="description" HeaderText="Description" />
    <asp:BoundField DataField="kind" HeaderText="Kind" />
    <asp:BoundField DataField="type" HeaderText="Type" />
    <asp:HyperLinkField DataNavigateUrlFields="address" DataNavigateUrlFormatString="https://maps.google.com/maps?q=745+W+Colfax+Ave+Denver+CO+80204" DataTextField="address" HeaderText="Address" />

How do I go about doing this?


Two things that come to mind....

DataNavigateUrlFormatString would be ... http://maps.google.com/maps?q={0}. The data will be filled from the DataNavigateUrlFields.

To replace spaces for +, I would handle that part in the SQL query.

That seems to work good. I guess Google Maps does not really need the + between each string in the address. Thanks!

Good to hear. Feel free to mark the thread as solved if you do not need additional help.