开发者

asp.net - continuously update grid

开发者 https://www.devze.com 2023-03-20 06:00 出处:网络
I have an asp.net web app. The main thread starts a child thread which populates (at a high rate) a DataTable with random generated data. I keep开发者_如何学Go the DataTable in the Application object.

I have an asp.net web app. The main thread starts a child thread which populates (at a high rate) a DataTable with random generated data. I keep开发者_如何学Go the DataTable in the Application object.

I want to bind a gridview to this DataTable each time a new row is added to the table.

How can i accomplish this? How can the main Thread call DataBind on my GridView every time DataTable gets updated?

Thank you.


Binding a grid in the view to a dataset in the application requires a postback. If you are programmatically adding rows at a high rate you will either need to do a ton of postbacks for each insert (which will get messy) or be satisfied with a normal frequency of postbacks.

If you want to put them into the grid quickly without postbacks you'll need to add them to the view with a script then postback to the application on a schedule.


No it cannot. Your best bet is to put this either in an update panel with a timer that checks for updates, or an ajax call to check if the rowcount has changed, if so then update your update panel. There are other 'less easy' options like push notifications (ie comet framework)

What are you trying to accomplish that must have the real time update? Most web apps use a polling technique to check the server.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号