You must Sign In to post a response.
  • Category: JQuery

    Find out how many checkboxes are checked

    I have two different grids. When i click a edit button of grid 1, grid1's total number of checked checkboxes should be tracked and if more than one checkboxes is checked i have to display message. The same applicable to grid 2 also.

    Please send the query in detail.


    Thanks in advance
  • #755522
    The below worked for me:

    var checkedCount = $("input:checkbox[id*=checkboxId]:checked").length;

  • #755532
    Good keep going to find solutions by your own, that is the best way to do practise.
    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #755541
    Hi,

    for checking how many checkbox are checked inside gridview u check the below code like as follow:

    $('#BtnExportToExcel').click(function () {
    var check = $('#GridViewID').find('input.checkbox:checked').length;
    alert(check);
    return false;
    }):

    in alert message its shows u the total no checkbox checked.hope this code helpful for uuu..


    Thanks,
    chitaranjan

  • #756243
    var selectedCheckboxes = [];
    $('input:checkbox[id$=CheckSelect]:checked', gridView1Control).each(function (item, index) {
    selectedCheckboxes.push(item);
    });

    if(selectedCheckboxes.length > 1)
    {
    //display your message.
    }

    Thanks & Regards,
    Abhijith

    Mail - abhijith.pn@gmail.com
    Check My Blog - http://www.solvemytechissue.in/

  • #757555
    Hi,

    you can identify this with jquery and yu can manage the things like check uncheck etc just verify the code snippet given bellow
    function OnEdit_Click()
    {
    var ele = $("#GridId input.checkbox:checked");
    if(ele.length>1)
    {
    alert("you are selected "+ele.length+" records");
    }
    else if(ele.length==1)
    {
    alert("you are selected one record");
    }
    else{
    alert("no records were selected");
    }
    }


    Regards
    SriSunny

  • #761037
    Hi
    Kumersh

    You can try this code for your issue

    Client Code

    <asp:GridView ID="grd1" runat="server" AutoGenerateColumns="false">
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:CheckBox ID="Chk1" runat="server" />
    </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="NAme" HeaderText="NAme" />
    <asp:BoundField DataField="EmpID" HeaderText="EmpID" />
    <asp:TemplateField>
    <ItemTemplate>
    <asp:LinkButton ID="lnk1" runat="server" Text="Click" OnClick="lnk1_Click"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>



    Server Side

    protected void lnk1_Click(object sender, EventArgs e)
    {
    int i = 0;
    foreach (GridViewRow item in grd1.Rows)
    {
    CheckBox chckNo = (CheckBox)item.FindControl("Chk1");
    if (chckNo.Checked)
    {
    i = i+1;
    }
    }
    Response.Write(" Total Check boxes " + i);
    }


    I have attached Image given below.

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

    Delete Attachment


  • Sign In to post your comments