Wrox Programmer Forums
|
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 February 8th, 2006, 11:58 AM
Authorized User
 
Join Date: Dec 2005
Posts: 77
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to g_vamsi_krish
Default Toggle CheckBox

Hai,
   I want to have a toggle check box in my datagrid.
I had a datagrid i want to hava a check box in the datagrid header or templete column. If i check that check box, it should check all the check box in that column. And this should happen in the client side. I saw the same functionality in yahoo or gmail.

                                     thank in advance.




vamsi
__________________
vamsi Krishna G
mobile: 91 + 9986023966.
124 Puttappa layout new Tippasandhra,
bangalore.
Inida
 
Old February 13th, 2006, 03:00 AM
Authorized User
 
Join Date: Dec 2005
Posts: 77
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to g_vamsi_krish
Default

This is the sample code for the Toggle check boxes.

we need to use java script function for selecting and un selecting the check boxes.


// code for selecting and deselecting checkboxes

    function select_deselectAll (chkVal, idVal)
    {
        var frm = document.forms[0];
        // Loop through all elements
        for (i=0; i<frm.length; i++)
        {
            // Look for our Header Template's Checkbox
            if (idVal.indexOf ('CheckAll') != -1)
            {
                // Check if main checkbox is checked, then select or deselect datagrid checkboxes
                if(chkVal == true)
                {
                    frm.elements[i].checked = true;
                }
                else
                {
                    frm.elements[i].checked = false;
                }
                // Work here with the Item Template's multiple checkboxes
            }
            else if (idVal.indexOf ('DeleteThis') != -1)
            {
                // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
                if(frm.elements[i].checked == false)
                {
                    frm.elements[1].checked = false; //Uncheck main select all checkbox
                }
            }
         }
    }
================================================== ==========================================



This is aspcode.

<form runat="server" ID="Form1">
    <h3>Selecting, Confirming &amp; Deleting Multiple Checkbox Items In A DataGrid
        (i.e. HotMail &amp; Yahoo)</h3>
    <br>
    <ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="white" BorderColor="black"
        CellPadding="3" CellSpacing="0" Font-Size="9pt" AutoGenerateColumns="False" HeaderStyle-BackColor="darkred"
        HeaderStyle-ForeColor="white">
        <Columns>
<asp:TemplateColumn>
                <HeaderTemplate>
                    <asp:CheckBox ID="CheckAll" OnClick="javascript: return select_deselectAll (this.checked, this.id);"
                        runat="server" />
                    a
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="DeleteThis" OnClick="javascript: return select_deselectAll (this.checked, this.id);"
                        runat="server" />
                </ItemTemplate>
            </asp:TemplateColumn>
// ... Rest of our Custom Template & Bound Columns
</Columns>
</form>


vamsi





Similar Threads
Thread Thread Starter Forum Replies Last Post
hi xml toggle effect gauravkg XSLT 1 September 8th, 2006 09:04 AM
Toggle/Drilldown help...please!!! s15199d Reporting Services 4 March 24th, 2006 04:11 PM
Toggle Buttons ctekk2005 Access 3 June 15th, 2005 03:36 AM
Toggle Key calvados VB.NET 2002/2003 Basics 2 December 17th, 2004 10:55 AM
Language toggle dsunmedia PHP How-To 2 August 2nd, 2004 11:00 AM





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