使用 IAsyncResult 更新 updatepanel 内的 DataRepeater 不起作用!

发布于 2024-09-27 13:53:59 字数 831 浏览 0 评论 0原文

当我使用 ISyncResult 时,我在将数据绑定到数据转发器时遇到问题。 这就是我正在做的事情。 更新面板内有一个按钮,用于获取用户的输入并调用一个返回数据集的函数,然后将其绑定到也在更新面板内的数据重复器。 我所做的是我做了一个委托给这个函数,现在我像这样调用这个函数

Dim caller As New AsyncMyFunction(AddressOf MyFunction)

然后我像这样创建一个 IASyncResult :

 Dim result As IAsyncResult = caller.BeginInvoke(argument1, argument1, AddressOf MyFunctionCallBack, Nothing)

这是回调方法:

 Sub MyFunctionCallBack(ByVal ar As IAsyncResult)
    Dim result As AsyncResult = CType(ar, AsyncResult)
    Dim caller As AsyncMyFunction = CType(result.AsyncDelegate, AsyncMyFunction)
    Dim ds As New DataSet
    ds = caller.EndInvoke(ar) 
    MyRep.DataSource = ds
    MyRep.DataBind()

End Sub

我很难弄清楚为什么数据转发器没有显示数据。 在调试时,我看到数据集正在获取数据并传递“ds”,但即使在调试时数据被传递到数据转发器内的控件,我的页面上也没有显示任何内容。

I am having trouble binding data to data repeater when I use ISyncResult.
This is what I am doing.
There is a button inside a Update Panel that gets the input from the user and calls a function that returns a dataset that I then bind to data repeater which is also inside a update panel.
What I did is that I made a delegate to this function, now I am calling this function like this

Dim caller As New AsyncMyFunction(AddressOf MyFunction)

And then I make a IASyncResult like this :

 Dim result As IAsyncResult = caller.BeginInvoke(argument1, argument1, AddressOf MyFunctionCallBack, Nothing)

this is the Callback method:

 Sub MyFunctionCallBack(ByVal ar As IAsyncResult)
    Dim result As AsyncResult = CType(ar, AsyncResult)
    Dim caller As AsyncMyFunction = CType(result.AsyncDelegate, AsyncMyFunction)
    Dim ds As New DataSet
    ds = caller.EndInvoke(ar) 
    MyRep.DataSource = ds
    MyRep.DataBind()

End Sub

I am having hard time figuring out why the data repeater is showing no data.
While debugging this I see that the dataset is getting the data and is passing the the "ds" but nothing is showing up on my page even though the data is being passed to controls inside data repeater while I am debugging.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淤浪 2024-10-04 13:53:59

它不是那样工作的。 BeginInvoke() 是一种调用异步方法的方法,并不意味着它可以与异步回发一起使用。 BeginInvoke() 在本地环境中是异步的,而异步回发只是远程环境中的部分 html 更新。
这是两件不同的事情。你需要完成你的数据集 b4 你调用 databind

its not work that way. BeginInvoke() is a way to call method async and it doesn't mean it gonna work with async postback. BeginInvoke() is async in local environment while async postback is just partial html update with remote environtment.
it's 2 different things. u need to complete your dataset b4 u call databind

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文