Reputation: 1460
I bind datalist on callback event. on click of a button inside the datalist need a postback to fetch data for another datalist. but after postbacking, no datalist is visible on the page. I dont know whats happening on postback. Please help me for finding a solution....
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
thank you
Upvotes: 0
Views: 445
Reputation: 10030
Data source items are not accessible after initial loading. They are available on databound only.
In your case, you can use HiddenField to store the Ids during post and then fetch data by that ID instead of dataitem because dataitem wont be available after postback.
Upvotes: 1