2012-07-29 2 views
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 

ERROR : 디버깅 된양식 내 Google지도에 라벨을 바인딩하는 방법은 무엇입니까?

Object reference not set to an instance of an object.

는 : 라인 정지는 : streetAddres = EventLabel.Text

+0

EventLabel이 (가) 존재하지 않습니다. Event_locationLabel 참조가 없습니다. – Jones

답변

0

문제 Event_locationLabel 유효한 제어 ID 없다는 것이다. 페이지를 검토하여 무엇이 호출되어야하는지 확인해야합니다.

어떤 이유로 페이지 소스에 대한 액세스가 차단 된 경우 인터넷 익스플로러를 열고 F12 키를 눌러 개발자 도구에 액세스 할 수 있습니다. 이것은 페이지의 요소를 식별하고 조정할 때 매우 편리합니다.

+0

답변 해 주셔서 대단히 감사합니다. 내 Event_LocationLabel은 내 데이터베이스에서 가져온 레이블이며 주소입니다. FormView의 라벨 주소에서 googlemap을로드하려고합니다. – Alexis1992

+0

라벨이 페이지에 어떻게 추가됩니까? 페이지에서 컨트롤을 찾으려고하는데 거기에 있지 않으므로 컨트롤을 추가하는 위치 나 액세스하려는 위치에서 문제가 될 수 있습니다. –

+0

", false) });