How to check how many check boxes are checked in the gridview


I am trying to make a javascript client fucntion to restrict no more then two rows could be selected
I have following in the itemtemplate of the gridview [although it is telerik control but same technique should be applied]
 <radG:GridTemplateColumn UniqueName="chkCheck">
                    <HeaderStyle  HorizontalAlign="Right" />
                    <HeaderTemplate>
                        <asp:Label runat="server" ID="lblEntity" Text="EntityID" />
                    </HeaderTemplate>
                    <ItemStyle  HorizontalAlign="Right" />
                    <ItemTemplate>
                        <%--<asp:CheckBox ID="chkItem" runat="server" CssClass="check" />--%>
                        <input type="checkbox" class="check" id="chkItem" onclick="TestFunction();" />
                        <asp:Label runat="server" ID="lblEntityID" Text='<%#Eval("Entity.ID")%>'   />                        
                    </ItemTemplate>
                </radG:GridTemplateColumn>  
Now please tell me in the TestFucntion how can i check that
I will follow the following technique http://www.htmlgoodies.com/tutorials/forms/article.php/3479181 
But I don't know how to go through it 

Kamran Shahid
Sr. Software Engineer
(MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
Netprosys Inc.
www.netprosys.com

Remember to click "Mark as Answer" on the post that helps U
0
kamii47
5/18/2007 7:36:05 AM
📁 asp.net.client-side
📃 24353 articles.
⭐ 2 followers.

💬 1 Replies
👁️‍🗨️ 1272 Views



Done it through 
function KeepCount()
{    
    var grid = document.getElementById('<%= grdCreditCheckDialog.ClientID %>');
    var inputs = grid.getElementsByTagName('input');
    var newCount = 0;
    for(var i = 0;i<inputs.length ;i++)
    {
        if(inputs[i].type == 'checkbox')
        {          
            if(inputs[i].checked)
            {               
                newCount = newCount + 1               
            }
            if (newCount == 3)
            {
                alert('Pick Just Two Please');               
                return false;
            }
        }
    }
}

Kamran Shahid
Sr. Software Engineer
(MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
Netprosys Inc.
www.netprosys.com

Remember to click "Mark as Answer" on the post that helps U
1
kamii47
5/22/2007 7:57:36 AM
Reply: