Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 23rd, 2004, 08:24 AM
Registered User
 
Join Date: Oct 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple Checkboxes With same name how to make t

Hi All,

I am dynamically generating checkboxes from my database depending on some field. i am assigning value for those too.

my statement is

dim tdnew as tablecell
tdNew.Text = "<input type='checkbox' id='cbxFChk' Name='cbxFChk' Value ='" & dsSet.Tables(0).Rows(i).Item("Productid") & "'>"

With The Above Statement i am generating more than 10 at a time per page. I Need to check those all at once as there in yahoo "Check All" and "Clear All" Links.

Anyone can help Me In This Issue.

Thanks
Chandu
 
Old October 29th, 2004, 09:03 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Hi,
    put 2 server button controls on your webpage:
    btnCheck - which checks all checkboxes called cbxFChk
    btnUncheck - which unchecks all checkboxes called cbxFChk

    ( cbxFChk being the name of your checkbox items in your
      HTML code in your question

     dim tdnew as tablecell
     tdNew.Text = "<input type='checkbox' id='cbxFChk'
     Name='cbxFChk' Value ='" & dsSet.Tables(0).Rows(i).Item
     ("Productid") & "'>"

    then add these 3 subs to your code which will check/uncheck
    all occurences of chkFChk checkboxes - see following code

   Private Sub btnCheck_Click(ByVal sender As System.Object,
     ByVal e As System.EventArgs) Handles btnSelectAll.Click
        SetSelected(True) 'checks the check box
    End Sub

    Private Sub btnUncheck_Click(ByVal sender As System.Object,
      ByVal e As System.EventArgs) Handles Button1.Click
        SetSelected(False) ' uncheck the check boxes
    End Sub

    Private Sub SetSelected(ByVal fState As Boolean)
        Dim i As Integer
        Dim aItem As DataGridItem
        Dim aCheck As CheckBox

        For i = 0 To gridSR.Items.Count - 1
            aItem = gridSR.Items.Item(i)
            'find all occurences of checkboxes in the datagrid
            '...that are called cbxFChk
            aCheck = aItem.FindControl("cbxFChk")
            aCheck.Checked = fState ' set checked property true/false
        Next

    End Sub

Hope this helps you. if you need the Javascript code to set the
checkboxes using HTML client side controls - then let me know and
i will getback to you.

best of luck
Chas (Canterbury, UK)







Similar Threads
Thread Thread Starter Forum Replies Last Post
to make checkboxes visible in datagrid C# windows bhavna General .NET 1 March 5th, 2007 10:41 AM
multiple checkboxes with same name how to checkAll kcs_chandra ASP.NET 1.0 and 1.1 Professional 1 October 23rd, 2004 08:53 AM
Multiple Checkboxes Error mgreenwood BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 May 27th, 2004 02:43 PM
multiple dynamic checkboxes mlog Classic ASP Basics 0 February 14th, 2004 04:49 AM
Cannot get multiple delete using checkboxes workin gmizzell Classic ASP Databases 0 July 13th, 2003 04:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.