Databinding in VWD 2005 Express
I am using Visual web developer express for my coding and work. I have a Dataset created in the Codebehind file and I need to bind the information to a Datagrid I have on my .aspx file upon page_load.I have tried debugging and building but for some reason, my dataGrid does not get bound to the Datasource ... Same thing I notice when I use ASP.NET matrix to build my pages. Could someone please tell me what I am missing here??Is there something I need to do before this can work??
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim zipCode As Integer
zipCode = Session("zip")
Dim weatherService As com.ejse.www.Service = New com.ejse.www.Service()
Dim weatherInfo As com.ejse.www.WeatherInfo = weatherService.GetWeatherInfo2("USERNAME", "PASSWORD", zipCode)
DG1.DataSource = weatherInfo
DG1.DataBind()
End Sub
[946 byte] By [
Reaction] at [2007-11-11 8:48:05]

# 1 Re: Databinding in VWD 2005 Express
It doesn't look like GetWeatherInfo2 returns a bindable data type, such as a DataSet, so you won't be able to bind it directly to a DataGrid. I would probably do something like this instead:
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
Dim zipCode As Integer
zipCode = Session("zip")
Dim weatherService As com.ejse.www.Service = New com.ejse.www.Service()
Dim weatherInfo As com.ejse.www.WeatherInfo = _
weatherService.GetWeatherInfo2("USERNAME", "PASSWORD", zipCode)
litLocation.Text = weatherInfo.Location
litZipCode.Text = zipCode.ToString()
litTemp.Text = weatherInfo.Temprature
litWind.Text = weatherInfo.Wind
litForecast.Text = weatherInfo.Forecast
End Sub