Select multiple checkboxes

Discussion in 'ASP .Net' started by Peter Afonin, May 11, 2005.

  1. Peter Afonin

    Peter Afonin Guest

    Hello,

    I have 5 checkboxes in one record in the datagrid. When the user checks 5th
    checkbox (or, in my case, clicks the button - doesn't matter to me), all
    other checkboxes are checked as well.

    I've done it in SelectedIndexChanged event. My code is below.

    However, it takes too long to work on the server side. I'm sure it is
    possible to do the same in Javascript. Unfortunatley, I don't know it that
    well. I've found many examples how to select all checkboxes in one column
    using JS, but couldn't find anithing about selecting them in one row.

    Could you please tell me how to do this in JS? I would appreciate it very
    much.

    My VB.NET code is here:

    Private Sub dgData_SelectedIndexChanged(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles dgData.SelectedIndexChanged

    Try

    Dim chk As CheckBox, btn As Button

    Dim i As String = dgData.DataKeys(dgData.SelectedIndex.ToString)

    btn = CType(dgData.SelectedItem.FindControl("btnAll"), Button)

    chk = CType(dgData.SelectedItem.FindControl("chkFront"), CheckBox)

    If chk.Checked = False Then

    chk = CType(dgData.SelectedItem.FindControl("chkPayout"), CheckBox)

    chk.Checked = True

    chk = CType(dgData.SelectedItem.FindControl("chkVarData"), CheckBox)

    chk.Checked = True

    chk = CType(dgData.SelectedItem.FindControl("chkQA"), CheckBox)

    chk.Checked = True

    chk = CType(dgData.SelectedItem.FindControl("chkFront"), CheckBox)

    chk.Checked = True

    chk = CType(dgData.SelectedItem.FindControl("chkEPS"), CheckBox)

    chk.Checked = True

    btn.BackColor = Color.FromKnownColor(6699)

    Else

    chk = CType(dgData.SelectedItem.FindControl("chkPayout"), CheckBox)

    chk.Checked = False

    chk = CType(dgData.SelectedItem.FindControl("chkVarData"), CheckBox)

    chk.Checked = False

    chk = CType(dgData.SelectedItem.FindControl("chkQA"), CheckBox)

    chk.Checked = False

    chk = CType(dgData.SelectedItem.FindControl("chkFront"), CheckBox)

    chk.Checked = False

    chk = CType(dgData.SelectedItem.FindControl("chkEPS"), CheckBox)

    chk.Checked = False

    btn.BackColor = Color.White

    End If


    --
    Peter Afonin
     
    Peter Afonin, May 11, 2005
    #1
    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. Ratman
    Replies:
    2
    Views:
    1,543
    Ratman
    Jul 4, 2004
  2. Peter Afonin

    Select multiple checkboxes

    Peter Afonin, May 11, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    148
    Peter Afonin
    May 11, 2005
  3. Matt
    Replies:
    2
    Views:
    209
    Roland Hall
    Jan 11, 2004
  4. palmiere
    Replies:
    1
    Views:
    413
    Erwin Moller
    Feb 9, 2004
  5. Ferd Berfel
    Replies:
    4
    Views:
    151
Loading...

Share This Page