We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 192,189 times

Contents

Related Categories

Selecting, Confirming & Deleting Multiple Checkbox Items In A DataGrid (i.e. HotMail & Yahoo) - Getting Started

DMarko1

Getting Started

Our fully-featured DataGrid

Selecting & deleting multiple items will definitely be set up quite differently than any other type of .NET DataGrid deleting you probably have seen. However, we'll still follow the same logical flow of deletion, and we'll still confirm any delete actions about to take place after we have selected all our items. Much of the magic in making this work is really going to come from client-side JavaScript, that is ultimately responsible for wiring up our main "select all" checkbox to handle the selecting and deselecting of our checkboxes. Also, included is our server-side delete method that erases our data, and a DataGrid refresher method to rebind our DataGrid after we have completed our data deletion.

Have a look at Figure 1 to get an idea of what your DataGrid will look like:

Figure 1

Here is the code to set up our DataGrid:

<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" />
                    <font face="Webdings" color="white" size="4">a</font>
                </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>

The code listed above is what makes our DataGrid set up behave just like the grids on Hotmail and Yahoo. Our .NET DataGrid will have the same functionality and options available for selecting however many items, or perhaps all, that you'd like to delete, and once you do and submit, kiss them goodbye.

Dimitrios, or Jimmy as his friends call him, is a .NET developer/architect who specializes in Microsoft Technologies for creating high-performance and scalable data-driven enterprise Web and desktop applications. Till now Jimmy has authored nearly two dozen .NET articles, published on Dot Net Junkies, 4 Guys From Rolla, Sitepoint, MSDN Academic Alliance, Developers.NET, The Official Microsoft ASP.NET Site, and here on Developer Fusion, covering various unique and advanced techniques on .NET.

Comments

  • Re: datagrid having multiple checkboxes with confirm d

    Posted by suhasini51 on 05 Dec 2006

    Hi,


      I required the same concept as in yahoomail.i am getting checkall and uncheckall in the grid.if all the items in the grid manually is checked then automatically the header c...

  • Re: [4632] Selecting, Confirming &amp; Deleting Multiple Checkbox Items In A DataGrid (i.e. HotMail &amp; Yahoo)

    Posted by Shafiqm on 25 Apr 2006

    I like your article regarding checkboxes. I have very interesting situation, can you please help me how I can solve this.


    My Gridview contains a template column which contains a checkboxlis...

  • Posted by ttvan01 on 03 Nov 2005

    Holly10sun,

    Can i ask what you did to get the selecting of each box to work? I also removed the Select All option, by removing the onclick/OnCheckedChanged from the HTML, but that alone didn't do...

  • multi check box in VB

    Posted by holly10sun on 03 Nov 2005

    I don't know if anyone got through this error. I was not able to fix the issue with the regiis suggestion either. I just took out the ability to click on box to select all and made the user select e...

  • javascript not a member of...

    Posted by ttvan01 on 02 Nov 2005

    I get the same javascript error. Tried running aspnet_regiis -i, but that didn't do the trick. did anyone else get this same error, if so how did you resolve it?