Submit batch entry in datatables.net - asp.net

I am using ASP.Net webform for my development and currently implement datatables.net. to perform some excel like data entry job. For more info, please go to http://datatables.net/release-datatables/extras/KeyTable/editing.html. I also added some add row and delete row functions at client side. Now I am stuck on how to push the entire table data to the server. It's look like excel and user can make the amendment. Whenever they plan to save the data, the user just need to click on save button and the entire table info shall be submitted to the server. For your information, no input textbox in this case because I am using keytable feature.
Please help!
Thanks.

I believe this datatables.net server side usage page has sServerMethod which may be fullfill your requirement. The data are passing in JSON format to server. In server side you can parse the JSON back to your DTO to update your data.

You can SqlBulkCopy for faster insertion of data in the database. You can search code for that on net.

You'll need to create an object collection of some kind in your handler to temporarily save the data into some kind of structure or object. What I did was append a row_id to the table row in the fnRowCallback of the Datatable, then grabbed it in the submitdata property of the Editable plugin, sending it to the server. Once there, I store it in an object, add it to the collection, and let editable update the table.
When you are ready to submit, fire it off, go to the handler, and send all of the data in the collection to the server as a mass update.

Related

saving data in asp.net form temporarily

I have one requirement of saving data in asp.net form temporarily. I want to re load the saved data in form controls, if on any error or session time out.
Can any body give solution for this?
Thanks in advance.
Save the data in hidden fields as you enter data in hidden fields on key press..Use angular-js for this which makes your work easy,since it supports two way binding.
Upon session expiry retrive the data in hidden fields to the user controls.
The second option is Use Update Panel in the ajax tool kit.
Happy Coding

Razor MVC - Object Edit Field Change Log

Users modify a DB object in an edit form that I have, pretty straight forward.
I need to implement a 'change log' on this object. I need to record which fields where changed and what they were before and after. I'm using Razor MVC.
I've done this by writing triggers for the table on update/delete. On update/delete of a record, the trigger pushes the record to a History table, in a History database. This creates the change log. Then you would just need to display it; to identify the change would require evaluating each and every field.
There's nothing already built that wold do this for you that I know of.

Open a form from an InfoPath form with values from the first to the new

I have been working with InfoPath forms for the last two months or so, and I now have the following requirement:
I have a form which is filled in by certain users, then sent to other users. The latter, after viewing the data on the form, have the possibility to either Accept & Reply or Reject.
When they click on Accept & Reply, another form is triggered, in which some of the fields are repeated. I would like to know how to get the values from the first form to that triggered form.
Let me precise that I am not using SharePoint; they are accessing the forms from a shared folder on the LAN.
Thanks in advance for your help on this.
Yusuf
That I know of you can't directly access the new form since Infopath keeps all instances separate (SDI vs MDI). You need a "middle" storage location. A database isn't a bad idea if you have one available - when the user clicks the button, data is saved to the DB, then the new form is opened and reads from the DB on form load.
Another way we have used (which is equally as cumbersome), is to use a blank copy of the form itself (not the original xsn). It is bad because you have to manually keep the blank copy up to date if you change the template but works well for what you are doing. Only recommended if you REALLY need those fields populated and you don't have a DB you can use for temp storage.
Open your form template like you are going to fill in the form but just save a "blank" copy to the share (it will save as xml). The process behind the button on your source form is: create a unique copy of the blank form (we store them all in a subfolder that gets cleaned out nightly), programmatically open and edit that new blank copy (easy since it is xml) putting data in the correct fields, save the edited copy, open the edited copy for the user instead of the xsn.

updating batches of data

I am using GridView in asp .net and editing data with edit command field property (as we know after updating the edited row, we automatically update the database), and I want to use transactions (with begin to commit statement - including rollback) to commit this update query in database, after clicking in some button (after some events for example), not automatically to insert or update the edited data from grid directly to the DB...so I want to save them somewhere temporary (even many edited rows - not just one row) and then to confirm the transaction - to update the real tables in database...
Any suggestions are welcomed...
I've used some good links, but very helpful, like:
http://www.asp.net/learn/data-access/tutorial-63-cs.aspx
http://www.asp.net/learn/data-access/tutorial-66-cs.aspx
etc...
Well,
you can store your edited data in a DataTable in session. and then pass this data table as a bulk insert in to the database. 2 options are available for this
if you are using SQL Server 2005 you can use OpenXML to achieve this, as i have stated here
if you are using SQL Server 2008 youc an use Table Variables like i did here.
i hope it helps
First way:
Create session variable that will contain your DB object (DataTable or mapped objects).
The GridView should work with this instance instead of sending the data to the database.
Once editing is finished you may take the object from the session and save it in the way you normally do.
Second way:
I would use javascript to collect all changes on the client side while he is editing as a array of objects (each object is separate row).
Once the editing done, you can create json string from the collection and pass it to the server.
If your json object configuration is same as server class then you can use JavaScriptSerializer to deserialize your string into collection of object.
After that, you can save your objects in the way you normally do.

How to refresh a page when record in db table get changed in ASP.Net 3.5

I have a page that contains a Gridview showing a record from a db table e.g. "tblEmployee".
If a record is inserted/updated/deleted in that table then I need my page to be reloaded so that the gridview will show the updated records. Records may be inserted/updated/deleted from any other application.
To rebind the gridview I have to reload the page. Suppose I open the page in my browser and no postback is done. After 10 minutes a record is inserted into the table by some other apps. How can I reload the page automatically, not manually by clicking refresh button when the records in db table changed? I am using Sql server 2005 as DB and ASP.Net 3.5(C#)
Please suggest how to implement this.
Thanks.
Here's two approaches... one using a trigger, the other using SqlDependency. I would recommend using SqlDependency, but I'm outlining another approach because you indicated trouble with SqlDependency.
Create a table with columns for table name and last update date. Create a trigger on tblEmployee to update that table on any insert/update/delete.
When the page is loaded, you'll want to store the current last update date for the table. Depending on how your page is setup, you could store it in ViewState or as a hidden field on the page. Then you'll need to poll for changes. There are many ways to do this. You could write a simple Page Method that returns the last update date, call it from JavaScript, and compare it to the date you stored in the hidden field. Or you could use an UpdatePanel with a Timer control and compare to the value you stored in ViewState.
Now this approach hits the database more than necessary. If that's a problem, use SqlDependency with SQL 2005 or greater. Create a SqlDependency and insert the current date into the Cache with this dependency object. Poll this cache item from the page as described above. When the dependency changes (OnChange event), update the cache item date again.
I see not other option that having a polling mechanism, i.e. using setTimeout+jQuery or ASP.NET AJAX Timer that pulls the information at intervals.
Basically what you want is for the server to notify the client that an update has occurred and in a web/ASP.NET application communication is always initiated by the client. So polling is your only option.
You could use the SqlDependency class:
Here's a getting started example: SqlDependency in an ASP.NET Application (ADO.NET)

Resources