Select multiple checkboxes

P

Peter Afonin

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top