Public partial class TableExample : .Page Second when i click save button how i can read data from HandsonTable and convert back to my data table structre.
#Handsontable getdata code
( in code postable back happend due to save button click event)Ģ. I successfully populate my database data into the HandsonTable BUT whenever postback happend data disappear from the HandsonTable.
I am trying populate JQuery HandsonTable from codebehind and also want to get data from HandsonTable to save back into the database.ġ. This pattern is just hooking to data and serializing/deserializing it in a way that can be passed between the server and client, no matter what language the server is running. My solution here is not specific to Web Forms. It pulls the data out of the hidden field and uses JSON2 to deserialize the object out of the string and that result is passed to my handsontable create table method. My event just listens for the ready event of the page and then looks for that hidden field I created to save the data. So just as I did with my form submission event, I wrote a specialized page load event that populated an object for my handsontable to use during it's creation. With Web Forms and the page I was working with, I needed to be able to repopulate the table with data that had traveled across my PostBack event. Once it is on the server you can do what you need to do to this. If my table was completely valid, then the event would harvest the data from handsontable and with JSON2 serialize that data into a valid JSON string and save it into a hidden field that my code-behind would pick up.
#Handsontable getdata verification
Lastly, I used jQuery to bind an event on the form submission that ran a simple verification that there were no invalid cells in my table. I then added the JSON2 library, from Douglas Crockford's Github repository, to my project and included it in the page that the table is on. You can get that from the handsontable demo pages. I started out with creating everything I needed to render a blank handsontable to my page where I was replacing this old control. I did not try to create a Web Form custom element, instead I just took advantage of what was already implemented. My project that I was implementing handsontable was a classic example of Web Forms with PostBack and code behind access of form elements directly. The community around this is very helpful and this library is rapidly evolving into an even better library! I thank Marcin Warpechowski, for creating this wonderful library. After investigating several libraries I decided that handsontable provided me the best solution. I was working on replacing an old Excel web control with a more user friendly and needed a JavaScript library that provided the functionality that I needed. Protected void Page_Load(object sender, EventArgs e)ĭt = handler.dbQuery("Select Convert(varchar(5),Timeline) ,Isnull(Field1,'Information regarding'), Isnull(Field2,'special'), isnull(Field3,'Hello') From RumBokTimeline")