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 April 7th, 2004, 09:49 AM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting Checkbox Checked Property from OnClick

Hello.

I have a Repeater object displaying data for records returned from a database as well as a 'Select' checkbox for each reord, which is set at 'Checked' by default. I want to put a 'Deselect All' button on the page to allow the user to deselect all the records. How do I access the checked property for each item returned? Here is the Repeater:

<asp:Repeater id="objCountyRepeater" runat="server">
    <ItemTemplate>
        <table summary="Payee Information" border="0">
            <tr><td><asp:Checkbox id="cbxSelected" checked="True" runat="server" /></td><td colspan="2" width="600" style="text-align:left"><b><asp:Label Text='<%# Container.DataItem("Collectable") %>' runat="server" /> for: </b><asp:Label id="lblEntityName" visible="True" Text='<%# Container.DataItem("EntityName") %>' runat="server" /><asp:Label id="lblEntityOID" visible="False" Text='<%# Container.DataItem("EntityOID") %>' runat="server" /></td><td style="text-align:right"><b>Cert Costs: </b></td><td width="75"><asp:Label id="lblCertFees" Text='<%# DataBinder.Eval(Container.DataItem, "CertFees", "{0:C}") %>' runat="server" /></td></tr>
            ETC. ETC.
        </table>
  </ItemTemplate>

Thanks!

 
Old April 7th, 2004, 01:01 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to loop thru all the repeater's items, test for the right item types then you can find the checkbox control and set its checked property.

      For Each objItem In objCountyRepeater.Items
         Select Case objItem.ItemType
            Case ListItemType.AlternatingItem, ListItemType.Item, ListItemType.SelectedItem
               objCheckBox = CType(objItem.FindControl("cbxSelected"), CheckBox)
               If Not objCheckBox Is Nothing Then
                  objCheckBox.Checked = False
               End If
         End Select
      Next

Here's a working example. You can see the code for it there as well.
http://www.geekdork.com/samples/repeaterCheckboxes.aspx

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old April 8th, 2004, 09:33 AM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Peter. Works like a charm!

Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
checkbox in gridview and setting "checked" Snuffles ASP.NET 2.0 Basics 2 April 7th, 2007 05:15 AM
Checkbox checked all mateenmohd Javascript 1 January 2nd, 2007 06:19 AM
checkbox checked by default by html:checkbox sachin.tathod Struts 3 December 4th, 2006 03:41 PM
Checkbox checked? ninel ASP.NET 2.0 Professional 1 April 12th, 2006 10:50 PM
allow only one checkbox to be checked! morpheus HTML Code Clinic 5 April 15th, 2004 10:59 AM





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