简体   繁体   中英

Asp.net Grid View Check boxes to Text box

I got a minor problem. I am displaying data from a database table in a .aspx page in the form of a grid view.

The first column is check boxes for each individual row and a header check box to implement the check all and uncheck all functionality which I already did using javascriptC. The purpose is general purpose...ie each check box represents the row which it is present in.

The problem is as I check the check boxes- either some or all or none....the sum of the values in the selected rows should be displayed dynamically in a text box in the same page below.

Please tell me how to implement this functionality. Just a basic hint or syntax is sufficient. I will do the details myself.

Please tell me the functionality for a simple grid view with two columns- one check box and the other being some values. so I want to display the sum of selected values into a text box in the same page below. This is the problem in simple words.

Thanks in advance for the help.

Concept

Calculate method

create first a method that will iterate over all the items in the grid view, and it will verify if the column is checked, if the column is checked then you add the value to the result variable. At the end of the iteration you update the value of the textbox/label or whatever will display the calculated value

Event

then you will have to use the onCheckChange of the checkboxes or on click to call the "calculate method"

Code

to loop in the grid: Looping through GridView rows and Checking Checkbox Control

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM