| |

VerySource

 Forgot password?
 Register
Search
View: 686|Reply: 4

datagrid counts rows based on selection

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-20 22:00:01
| Show all posts |Read mode
A checkbox control is added to the datagrid. Is it possible to achieve such a function. That is: a variable is defined but the variable is increased by 1 when a checkbox is selected and subtracted by 1 when deselected. I.e. calculate the number of selected rows in real time
Reply

Use magic Report

0

Threads

9

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-6-26 15:15:01
| Show all posts
can
Can be achieved with js
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-26 17:00:02
| Show all posts
Please give pointers
Reply

Use magic Report

1

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-26 21:15:01
| Show all posts
After binding, add onclick event processing on Checkbox.
datagrid1.DataSource=dt;
datagrid1.DataBind();

for(int i=0;i<datagrid1.Items.Count;i++)
{
   CheckBok ck=(CheckBox)datagrid1.Items[i].FindControl("checkbox1");
   if(ck!=nul)
   {
       ck.Attributes.Add("onclick","CheckClick();return false;");
   }
}

As for the preparation of Js, please refer to some JS manuals for yourself
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-27 12:00:01
| Show all posts
Thank you for your guidance and experiment
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list