Help assigning a datasource to the gmap control in C#

Last post 07-04-2009 9:57 AM by liangchu. 1 replies.

Sort Posts:

  • Help assigning a datasource to the gmap control in C#

    09-18-2007, 6:36 PM
    • Member
      15 point Member
    • iggabriel
    • Member since 07-03-2006, 1:05 AM
    • Posts 24

    I'm trying to assign a datasource to a gmap control in 2.0 so that i can get pushpins in the map for all the locations in the sql db. I've enclosed my code below as well as a link to the site that provides the control and their sample. Can anyone tell me why it won't show the pins? What am I doing wrong?

    Thanks.

     My Code (sqllocations is a datasource):

    GMap1.DataSource = sqllocations;

    GMap1.DataBind();

    Their site: http://en.googlemaps.subgurim.net/ejemplos/ejemplo_991000_DataSource.aspx

    Their example (part of their explanation is not english, sorry):

     List<DataSourceField> fields = new List<DataSourceField>();

    fields.Add(new DataSourceField(45, 2, "hola"));
    fields.Add(new DataSourceField(46, 3));

    // Lo comentamos porque al utilizar la clase DataSourceField,
    // pero si fuera un dataset o cualquier otra cosa,
    // le deberíamos dar los nombres correspondientes
    // GMap1.DataLatField = "lat";
    // GMap1.DataLngField = "lng";
    // GMap1.DataGInfoWindowTextField = "gInfoWindowText";

    GMap1.DataSource = fields;
    GMap1.DataBind();  

     

  • Re: Help assigning a datasource to the gmap control in C#

    07-04-2009, 9:57 AM
    • Member
      2 point Member
    • liangchu
    • Member since 07-04-2009, 8:23 AM
    • Posts 1

     Hello!

    I see that this post is a little bit old, for other readers it might be helpful.

    Here:

    </P> <P>fields.Add(new DataSourceField(45, 2, "hola"));
    fields.Add(new DataSourceField(46, 3));</P> <P>

    Datasourucefield should be the actual name of the field in your dataset/datatable and not its value.

     


     

Page 1 of 1 (2 items)
Microsoft Communities