| |

VerySource

 Forgot password?
 Register
Search
View: 1200|Reply: 14

gridview select all

[Copy link]

2

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-2-23 17:30:02
| Show all posts |Read mode
Use checkbox to make a gridview full selection box, but as soon as one page or sort the selected records disappears, I don't know how to solve this
Reply

Use magic Report

0

Threads

29

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-5-6 13:15:01
| Show all posts
session save
Reply

Use magic Report

2

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-5-8 11:15:01
| Show all posts
Is there any other way?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-8 16:00:01
| Show all posts
To save the state, you have to use Session
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-8 20:45:01
| Show all posts
How did you select all
1. If you want to keep it, you must register CheckBox
 CheckBox check = ((CheckBox) gvlDestination.theGridViewList.Rows [i] .Cells [0] .FindControl ("check"));
                    check.Checked = true;
                    if (check! = null)
                    {
                        checkstr + = string.Format ("; document.all ['{0}']. checked = true", check.ClientID);
                    }
                }
                                JS.ExecuteBlock (this, checkstr);
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-8 21:30:01
| Show all posts
Use ViewState to turn pages
Reply

Use magic Report

2

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-5-10 12:15:01
| Show all posts
<script runat = "server">
protected void CheckAll (object sender, EventArgs e)
  {
    CheckBox cbx = (CheckBox) sender;
    foreach (GridViewRow gvr in gvComUnion.Rows)
    {
      CheckBox ch = (CheckBox) gvr.FindControl ("ItemCheckBox");
      ch.Checked = cbx.Checked;
    }
  }
</ script>
I wrote that
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-11 09:00:02
| Show all posts
This should be a problem
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-11 19:00:02
| Show all posts
Try this   

 CheckBox cbx = (CheckBox) sender;
    string checkstr;
    foreach (GridViewRow gvr in gvComUnion.Rows)
    {
        CheckBox ch = (CheckBox) gvr.FindControl ("ItemCheckBox");
          //ch.Checked = cbx.Checked;
          if (ch! = null)
        {
            checkstr + = string.Format ("; document.all ['{0}']. checked = true", ch.ClientID);
        }
    }
    Page.RegisterStartupScript ("key1", string.Format ("<script> {0} </ script>", checkstr));
Reply

Use magic Report

2

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-5-12 06:15:01
| Show all posts
protected void CheckAll (object sender, EventArgs e)
  {
      CheckBox cbx = (CheckBox) sender;
      string checkstr;
      foreach (GridViewRow gvr in gvComUnion.Rows)
      {
          CheckBox ch = (CheckBox) gvr.FindControl ("ItemCheckBox");
          //ch.Checked = cbx.Checked;
          if (ch! = null)
          {
              checkstr + = string.Format ("; document.all ['{0}']. checked = true", ch.ClientID);
          }
      }
      Page.RegisterStartupScript ("key1", string.Format ("<script> {0} </ script>", checkstr));
}
Is that right? Can not be done
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