如何在标签上显示插入数据库的当前金额? [英] How do I display current amount being inserted to the database on a label?

查看:78
本文介绍了如何在标签上显示插入数据库的当前金额?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

有没有人知道如何在每个循环中更改标签的价值



Hi
Does anyone have any Idea how I change the value of a label in every loop

Protected Sub BtnUpdateLbl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnUpdateLbl.Click
      For i As Integer = 0 To 20
           Me.lblChange.Text = i
           Threading.Thread.Sleep(1000)
           Me.UpdatePanel1.Update()
      Next
End Sub





我只得到循环的最后一个值。



我在想是否他们是实现这种情况的另一种方式。



我打算在进度条上使用它,以便用户知道当前插入/更新的金额该数据库。



I only get the last value of the loop.

I was thinking if theirs other way to achieve this scenario.

I was planning to use it on a progress bar so that the user will have idea of the current amount being inserted/Updated to that database.

推荐答案

您无法在ASP.Net中直接在C#中执行此操作。原因是网络是一种断开连接的媒介。这意味着当用户单击页面上的按钮时,会向运行C#代码的Web服务器发送一条消息。所有C#代码都会运行并最终生成HTML,然后将其发送回客户端。这就是你只看到最后一个的原因。网络根本不像Windows窗体那样工作。



你想要的是google有关如何在ASP.Net中显示进度的例子。您需要使用jquery的.ajax()而不是像现在这样的回发启动该过程。这样,您可以一次查询当前状态或从客户端进程查询。你需要重新考虑你想要做的事情。
You can't do this directly in C# in ASP.Net. The reason is the web is a disconnected medium. Meaning that when a user clicks a button on your page a message is sent to your webserver where your C# code runs. All of your C# codes runs and ends up generating HTML that is then sent back to the client. This is why you only see the last one. The web does not work at all like windows forms.

What you want is to google for examples of how to show progress in ASP.Net. You'll need to kick off the process with jquery's .ajax() instead of a postback like you have now. That way you can query for the current status or from the client side process one at a time. You'll need to rethink what it is you are trying to do.


这篇关于如何在标签上显示插入数据库的当前金额?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆