0

我在回调事件上绑定数据列表。单击数据列表中的按钮需要回发以获取另一个数据列表的数据。但回发后,页面上看不到数据列表。我不知道回发时发生了什么。请帮助我找到解决方案....

 If IsPostBack = False Then
        callback = ClientScript.GetCallbackEventReference(Me, "message", "processMyResult", "context")
        Dim script As String = "function CallBack(message,context){" + callback + ";}"
        ClientScript.RegisterClientScriptBlock(Me.GetType(), "CB", script:=script, addScriptTags:=True)


        callbackhotelsearch = ClientScript.GetCallbackEventReference(Me, "message", "processhotelsearchResult", "context")
        Dim scriptsearch As String = "function callbackhotelsearch(message,context){" + callback + ";}"
        ClientScript.RegisterClientScriptBlock(Me.GetType(), "CB", script:=scriptsearch, addScriptTags:=True)

        SearchTextBox.Attributes.Add("onkeyup", "javascrpt:LookUpStock()")
        SearchTextBox.Attributes.Add("onfocus", "javascript:SetCursorToTextEnd()")
    End If





 Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent

    If (eventArgument) Is Nothing Then

        returnValue = "-1"

    Else

        binddata(eventArgument)
    End If



    Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
    Dim sw As System.IO.StringWriter = New System.IO.StringWriter(sb)
    Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
    dataListPackages.RenderControl(hw)
    returnValue = sb.ToString()

End Sub

Public Function GetCallbackResult() _
As String Implements _
System.Web.UI.ICallbackEventHandler.GetCallbackResult

    Return returnValue

End Function

Public Function binddata(ByVal eventArgument As String) As Nullable
    Dim adp As New dsRegistrationTableAdapters.searchPackagesTableAdapter()
    Dim dt As New dsRegistration.searchPackagesDataTable()
    dt = adp.GetData(eventArgument, StartDateTextBox.Text, EndDateTextBox.Text)
    'StartDateTextBox.Text = "11-12-2012"

    dataListPackages.DataSource = dt
    dataListPackages.DataBind()
    SearchTextBox.Focus()
    Return Nothing
End Function

谢谢你

4

1 回答 1

1

初始加载后无法访问数据源项。它们仅在数据绑定上可用。

在您的情况下,您可以使用 HiddenField 在发布期间存储 Id,然后通过该 ID 而不是 dataitem 获取数据,因为回发后 dataitem 将不可用。

于 2013-02-04T10:38:50.620 回答