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 に答える