Refreshing webform when database is externally updated - c#

For experimental purposes i've made a ASP.net webform that writes to a database. Ive also made a windows form(c#) that writes to the same database.
The webform displays the text in a gridview and the winform displays the text in a datagridview.
My question is: is it possible to refresh the windows form and webform when the database is updated by the other? And if so, could anyone point me in the right direction?

George has suggested one good approach in his comment.
For ASP.Net, you could use SignalR to update the web page.
ASP.NET SignalR is a new library for ASP.NET developers that simplifies the process of adding real-time web functionality to your applications. Real-time web functionality is the ability to have server-side code push content to connected clients instantly as it becomes available.
The traditional approach would involve "polling" by the desktop app, that is, making a request every few seconds to see if there is new information. This approach can be resource-intense. You can also do polling from a web page, of course.

The simplest way to do this to use two timer controls, one in the WinForm and the other on the WebForm.
And at desired intervals just rebind the dataset.
Rebind Data
grdWaiver.DataSource = dv 'Set the dataview to the DataGrid
grdWaiver.DataBind()
(In above I used a dataview as a datasource)

Related

Using ASP.Net Web Databound Controls to create Jquery Sliders tickers type controls

I am working on a B2B portal web app, where i need to display upcoming news , products and company info on regular interval (say as slideshows and tickers).
For example :
Scenario 1. I need to display the latest company(registered in this week) in a marquee style. Where companies will be pulled out from database.
Scenario 2: I have some products categorized as hot products, that will be displayed as slideshow on the home or somewhere else.
I know using Jquery and Static pages its possible. But i havent idea about how to do this with ASP.Net databaound controls like grid, repeaters, datalist etc. We are not in favour of purchasing third party controls, instead it will be a last resort for us.
Please help me through buil-in controls. Any help will be highly appreciated.
You should decide whether you want to do with JQuery Widgets or ASP.NET controls (or third party ASP.NET controls like Telerik). Can you use both - yes you can, but you are only going to add more complexity to your app because ASP.NET controls don't know about your JQuery Widgets and you have to provide the glue to tied them both and keep them synched up. So if you decide to build everything in JQuery - convert your static html pages to .aspx pages then add additional serverside functionality to return the data. For AJAX behavior, you can use what is called Page Methods in ASP.NET or write seperate Script Services. You will make use of what is called a ScriptManager. That way you can keep your existing markup and rely on ASP.NET to provide you with Data. The other alternative is to convert everything to ASP.NET Controls - and rely on the builtin or third-party control suite to provide the functionality.

jQuery 'viewstate'-like behavior

I'm building a website in jquery mobile. It is a SOA application and on 'pageshow' event I call the web services get the data and populate labels and dropdown lists with it. However, say for instance, when a user clicks back and the app takes him back to dashboard, the ajax call is made again and the labels are unnecessarily populated again. What I want to ask is, can I prevent this behaviour of populating the same labels with the same data over and over again? Does jquery mobile have this 'viewstate' behavior built in?
Thank you for taking the time to answer my question.
You could use HTML5's localStorage / sessionStorage API to actually persist data between callbacks.
Personally I think that if you'd use JQM's page idiom (having only data-role=page and not loading any new ajax pages), you wouldn't have this problem at all (but rather the opposite, how to reset all fields).

Inserting multiple records with one click in Telerik mvc grid

I am working on a Telerik MVC grid. My requirement is to allow a user to insert multiple records into the grid. This should be done on the client side.
After entering several records in the grid, the user will click a button so that all the records are inserted into the database.
Is this possible with Telerik MVC grid?
Thanks in advance.
Here is a guide for doing a batch update from Telerik themselves: http://www.telerik.com/help/aspnet-ajax/grdperformingbatchupdates.html
Here is a demo using automatic operations to allow multi-row editing: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx
Here is another ticket which links to a demo from Telerik doing this type of thing: http://www.telerik.com/community/forums/aspnet-ajax/grid/339723-batch-insert.aspx
Bottom line: it can be done, but it isn't super easy and will require quite a bit of custom code. More than I am able to share here, but the above links (especially the last one) should provide you the resources you need.
Not supported out-of-the-box from the Telerik MVC grid extensions AFAIK, but it should be possible by making jQuery ajax or web service calls which add items in the source and bind the grid. And I recently heard that they crafted batch client edits/updates for the Q1 2011 release, due in mid March.
The latest release of Telerik MVC Grid supports what's called batch editing directly. Here is the documentation on how to use the new feature.

Load 3 user controls (web application) on their own threads

I have 3 user controls that pull data from the database and display a gridview. I need all of these 3 gridviews to run at the same time.
How can I use threading to accomplish this?
I forgot to mention it is being developed in C#
Also, trying to create a thread in the page that is calling the 3 user controls is shutting down my localhost webserver whenever the thread is hit.
What is causing this?
Sorry for the late reply, hopefully I can still be helpful:
You probably want to look into ASP.NET async pages. There's a great writeup on MSDN Magazine: http://msdn.microsoft.com/en-us/magazine/cc163725.aspx
Almost half way down the page there's a header "Asynchronous Data Binding" that I believe addresses your issue.

Getting data out of a Silverlight control

I am relatively new to Silverlight development and I am trying to figure out how to get data out of a silverlight control that I have made.
I have a Silverlight control that gathers a bunch of graphical data points. The Silverlight control is embedding in a asp.net webforms application. The page that is displaying the control also does other data specific functions and when the user clicks a button I need to perform some manipulation of the data (both webform data and the data contained in the Silverlight control) and then save the data with 1 call to the DB.
My question is how do I get the data out of the Silverlight control from my webform to be able to put the data together for the save?
My initial thought was to make the data in the Silverlight control accessible via Javascript and then on the button click, save the Silverlight control's data to some html control and then allow the regular webform post to occur and read the data server side. Is there a better way to do this as it feels a little messy.
Note: I am using .NET 3.5 and Silverlight 3.0.
You have a lot of options:
You can have your Silverlight control submit the data directly to the server, using ADO.NET Data Services or a webservice call which processes the data
You can use RIA Services, which simplifies the process of interacting with server-side code from Silverlight
You can have the Silverlight control update a form field (hidden, probably) which then can be processed and submitted via the web page
Marc Gravell's protobuf-net library for silverlight may be an option for server side comms. Googles protocol buffers can comunucate with lots of lauguages.

Categories