i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
count checked check boxes inside gridview
08-29-2011, 01:29 PM
Post: #1
count checked check boxes inside gridview
the below simple javascript shows the number of checked checkboxes inside gridview

Code:
<script type="text/javascript" language="javascript">
        function CountChkBx() {
            var gvDisplayCart = document.getElementById("GV_UserAdStatus");
            var btn = document.getElementById("btn_Execute");
            var inputList = gvDisplayCart.getElementsByTagName("input");
            var numChecked = 0;

            for (var i = 0; i < inputList.length; i++) {
                if (inputList[i].type == "checkbox" && inputList[i].checked) {
                    numChecked = numChecked + 1;
                }
            }
            alert(numChecked);
        }  
    &lt;/script>

Code:
<asp:GridView AllowSorting="true" ID="GV_UserAdStatus" Width="98%" AutoGenerateColumns="False" runat="server">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="cb_count" runat="server" onclick="CountChkBx();"></asp:CheckBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="username" HeaderText="User Name" Visible="true" SortExpression="username" />
            </Columns>
        </asp:GridView&gt;




[Image: 2604595733.png]
Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  select checked checkboxes form gridview using jquery raju 0 4,458 10-05-2011 08:06 PM
Last Post: raju



User(s) browsing this thread: 1 Guest(s)