我正在尝试引用我的 ListView 控件来为其分配数据源。但奇怪的是,当我调试“Me.lvResults”时它是“无”是什么原因造成的?我倾向于调用作为默认类的一部分的 BindDataSearch() 函数的方法。我真的需要代码像这样工作,因为我 ajax 调用 Search(),但如果有人可以推荐更好的方法,我愿意接受建议。非常感谢您的宝贵时间,
Imports System.Web.Services
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
<WebMethod()>
Public Shared Sub Search(ByVal StartDate As String, ByVal EndDate As String, ByVal ClassName As String)
Try
'Get Search Results
Dim _DataHelper As New DataHelper
Dim dt As New DataTable
dt = _DataHelper.ClassSearch(StartDate, EndDate, ClassName)
'Bind Search Results to DateGrid
Dim _ClassSearch As New _Default
_ClassSearch.BindDataSearch(dt)
Catch ex As Exception
Dim strError As String = ex.ToString()
End Try
End Sub
Public Sub BindDataSearch(ByVal dt As DataTable)
Me.lvResults.DataSource = dt
End Sub
End Class