how to check all check boxes in repeater control

Discussion in 'ASP .Net' started by kris, Sep 22, 2005.

  1. kris

    kris Guest

    Hi All ,

    I am using a repeater control to display set of records. Now on the
    header template of the Reapeter control there is a Check Box .

    For each record that will displayed there will be a check box assigned
    to it.

    now when i cllick the Check box on the header template all the check
    boxes for the record displayed in repeater control have to be checked.

    can any one help me in this, can any one provide me a code sample to
    how do this.

    Thanks
    kris, Sep 22, 2005
    #1
    1. Advertising

  2. kris

    kris Guest

    I fiugured it out how to just do that.Propably if any one are searching
    for somethig like this , this would be really helpful


    protected void CheckAll(object sender, System.EventArgs e)
    {
    //sender= above sender in the function, who is sending that one
    CheckBox cMain= (CheckBox) sender;//creating a new check box
    if(cMain.Checked)//if checked header control
    {

    foreach(RepeaterItem ri in rpRepeater.Items)//checking all the
    repeater items .. one line in rc is a item
    if(ri.ItemType== ListItemType.Item)//if that item type is equal to
    check box
    {
    CheckBox cb=(CheckBox) ri.FindControl("cBox");//find control named
    cbox whicn is declared in
    cb.Checked=true; //HTML
    }
    }
    else// if again checked then de select all
    {
    foreach(RepeaterItem ri in rpRepeater.Items)
    if(ri.ItemType== ListItemType.Item)
    {
    CheckBox cb=(CheckBox) ri.FindControl("cBox");
    cb.Checked=false;
    }
    }

    }
    }

    Thanks
    kris, Sep 22, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kris
    Replies:
    0
    Views:
    499
  2. kris
    Replies:
    0
    Views:
    461
  3. Stefan Mueller
    Replies:
    5
    Views:
    12,347
    jamesxa
    Jun 16, 2009
  4. Suresh
    Replies:
    2
    Views:
    383
    Suresh
    Apr 22, 2004
  5. pw

    Check All Check Boxes

    pw, May 24, 2005, in forum: Javascript
    Replies:
    8
    Views:
    124
    Lasse Reichstein Nielsen
    May 25, 2005
Loading...

Share This Page