简体   繁体   English

Asp.net网格视图复选框到文本框

[英]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. 我正在以网格视图的形式在.aspx页中显示数据库表中的数据。

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. 第一列是每行的复选框,还有一个标题复选框,用于实现全部选中和取消选中我已经使用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" 那么您将必须使用复选框的onCheckChange或单击以调用“计算方法”

Code

to loop in the grid: Looping through GridView rows and Checking Checkbox Control 在网格中循环遍历GridView行和Checking Checkbox Control

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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