Preserve updates made by JavaScript to a data table (grid view)

I have a gridview where empty cells are filled with strings when clicked using javascript to manipulate the innerHTML property.

Now, I want to save these changes in a 2D array once the index of my combobox is altered. However, during the selectedindexchanged event, when I loop through the gridview, none of the cell changes are visible – all cells appear empty again. It seems like the changes made are not being saved persistently.

What steps should I take to address this issue?

Answer №1

Unfortunately, the changes you make in your form are not permanent. It is crucial to educate yourself on how web forms operate in order to gain a comprehensive understanding. Keep in mind that when you trigger the SelectedIndexChanged event, it essentially sends a POST request of the form on your webpage. Only form values, such as those within <input> or <select> elements, will be transmitted to the server for processing in your C# code. One workaround could involve creating a hidden input for each cell in your GridView. Another approach might entail using a single hidden input to store a string representation of a 2D array, which can be manipulated using JavaScript whenever cell contents change. When handling this data in your C# code, ensure that you extract information from the hidden inputs rather than directly from the GridView cells.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Resolving MYSQL Connectivity Problems through PHP Programming

I need help debugging the code for my 'PHP' website database. I'm having trouble connecting to MYSQL using the code below. My website is cruzapp, which focuses on rideshare companies. The goal is to switch to php to access user data. Here is ...

Unable to display items in controller with AngularJS

I am facing an issue with displaying a slider using ng-repeat in my AngularJS code. The pictures and other elements defined in the controller are not showing up on the page. Here is the JavaScript code snippet: angular.module('starter', []) .co ...

Tips for restricting the maximum characters in AngularJS?

I would like to limit the maximum number of characters in an input and textarea to 20 each. How can this be achieved? Any assistance is appreciated. <form novalidate name="editartistForm"> <div class="col-md-6 field_container"> <md-inpu ...

Encountering a hiccup during a join linq query操作oops!

I am currently working on this code snippet: public ActionResult JoinSupToPro() { SupplierDBContext dbS = new SupplierDBContext(); var innerJoinQuery = from pro in db.Products join sup in dbS.Suppliers on pro.SupplierId equals sup ...

Using querySelector() to target specific divs by their classes while excluding any other classes

I am attempting to retrieve only the first divs while excluding the second ones: <div class="_5pcr userContentWrapper"> <div class="_5pcr userContentWrapper _4nef"> After researching, I discovered that the querySelector function should be abl ...

What is the format required for specifying the end date and start date when using

Implementing the bootstrap datepicker. The Documentation doesn't specify the expected format for setEndDate or setStartDate. It refers to endDate option, which also lacks details on the required format. I want to set endDate and newDate based on a s ...

Processing Data with JavaScript

I am new to working with JavaScript, coming from the Python world. I need some assistance. Currently, I am retrieving data from the back end that has the following structure: { "Airports": { "BCN": { "Arrivals": [ ...

I'm encountering problems when trying to publish my WinForms application using third-party CLIs. Can anyone provide guidance on how to prevent the occurrence of the "The specified module could not be found" exception?

I am relatively new to C# and programming outside of Matlab. I have dedicated significant time to researching this particular issue. My program utilizes various 3rd party CLIs and native C DLLs, all designed for x64 architecture. These files are correctly ...

Merge the JSON data of homerun statistics with corresponding date information

The task at hand involves extracting "Dates" and "homeruns" from the provided .json file. The goal is to combine matching Dates together and sum up the homeruns corresponding to those dates. Currently, I have managed to display the combined Dates with thei ...

Activate Popover with Hover and simply click anywhere to dismiss

Currently utilizing Bootstrap 4 and intrigued by the popover feature that activates on hover and closes when clicked anywhere. I'm also interested in making links functional within the popover. Any suggestions or tips on how to achieve this? $(doc ...

Ensuring data integrity within table rows using Angular to validate inputs

I am using a library called angular-tablesort to generate tables on my webpage. Each row in the table is editable, so when editMode is enabled, I display input fields in each column of the row. Some of these input fields are required, and I want to indica ...

The ajax Success function fails to work when set to receive JSON data

My task involves adding an attendance record for a group of students within a classroom using a Bootstrap modal. Below is the code snippet for my Bootstrap modal, containing a form: <div id = "add_attendance_modal" class = "modal fade&qu ...

Passing parent HTML attributes to child components in Angular 2

Is there a way to pass HTML attributes directly from parent to child without creating variables in the parent's .ts class first? In the sample code below, I am trying to pass the "type=number" attribute from the parent to the app-field-label component ...

Activating the CSS :active selector for elements other than anchor tags

How can I activate the :active state for non-anchor elements using JavaScript (jQuery)? After reading through Section 5.11.3 of the W3C CSS2 specification in relation to the :hover pseudo selector in hopes of triggering the activation of an element, I stu ...

Display when moving up and conceal when moving down

Is there a way to make the div appear when scrolling up and down on the page? I'm new to jquery and could use some assistance, please. ...

What is the best method for a Windows Service to submit a request to the ABP Framework?

My goal is to develop a Windows Service that transmits data to the ABP Framework API. I've discovered that logging in is required to access the API with OAuth 2 authorization in the ABP Framework. Initially, I successfully established a console applic ...

Exploring the diversity of perspectives through Angular

Currently, I am in the process of integrating multiple views in Angular to address the footer issue on a website that I am constructing. I want to ensure that the information I have been studying and attempting to replicate is accurate. Here is what I have ...

Varied content types required for unique elements within form data

I am having trouble including the content-type application/json with the initial element of my form data. This is the code I am using: var fd = new FormData(); fd.append('addBank', JSON.stringify(reqData.addBank[0])); fd.append('bankProof& ...

The driver instance that has forked will never cease

Issues arise when attempting to run multiple browser windows in Protractor. The code snippet being tested is as follows: I create a new browser instance to perform certain tests. When input is entered into the original browser, it should not affect the ne ...

If an error occurs later in the function, `console.log` will not function properly

While debugging some code in Express.js using console.log statements, I encountered an issue where the console.log statements do not execute if there's an error in the function, even if that error occurs after the console.log statement. This behavior ...