0
Protected Sub FormView1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBinding

    Dim streetAddres As String = Nothing
    Dim EventLabel As Label = FindControl("Event_locationLabel")
    Dim findMap As GMap = FindControl("GMap1")

    Dim GeoCode As GeoCode = Nothing
    ' Get user typed text from text box
    streetAddres = EventLabel.Text
    ' pass your city name in the geo code request it return geo code
    GeoCode = findMap.getGeoCodeRequest(streetAddres)
    ' Add the geocode in
    Dim gLatLng As New GLatLng(GeoCode.Placemark.coordinates.lat, GeoCode.Placemark.coordinates.lng)
    ' Set center of map based on latitude and longitude coordinates
    findMap.setCenter(gLatLng, 16, GMapType.GTypes.Physical)
    Dim oMarker As New GMarker(gLatLng)
    ' Bind that marker data in google map
    findMap.addGMarker(oMarker)

End Sub

错误:

Object reference not set to an instance of an object.

已调试:停止在行:streetAddres = EventLabel.Text

4

1 回答 1

0

问题是这Event_locationLabel不是一个有效的控件 ID。您将需要检查该页面以查看它应该被称为什么。

如果由于某种原因阻止了对页面源的访问,您可以打开 Internet Explorer 并按 F12 访问开发者工具。这些对于识别(和调整)页面中的元素非常方便。

于 2012-07-29T03:02:59.323 回答