Click here to Skip to main content
15,886,556 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to count number of checkboxes checked/unchecked in gridview using asp.net

i am using this code in .aspx
XML
<asp:GridView ID="gridlob" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource2" width="50%"
          onrowdatabound="gridlob_RowDataBound" >
        <Columns>
            <asp:BoundField DataField="LOUPe_LOB" HeaderText="Line Of Bussiness"
                SortExpression="LOUPe_LOB" />

               <asp:TemplateField HeaderText="Grouping">


              <ItemTemplate>
                <asp:CheckBox ID="chkReimbursable" runat="server" />
                </ItemTemplate>
                </asp:TemplateField>

        </Columns>
    </asp:GridView>

and i write code in code behind like this
C#
DataRowView drview = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{

    CheckBox check = (CheckBox)e.Row.FindControl("chkReimbursable");
    
        if (drview[1].ToString() == "Y")
        {
            check.Checked = true;
            

        }

      else {
            check.Checked = false;

            
        
        }

My requirement if user have a chance to maximum 19 records after selecting 19 records he is trying to select another record the remaining checkboxes are disabled. and user select the checkbox each and every time count the no of records are selected and no of records are unselected
Posted
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900