Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to differentiate checked/unchecked checkboxes in gridview .if i select 19 records it's ok.if i am trying to select 20 record that's time remaining uncheck records checkboxes will be disabled.

i am using this code


C#
int j = 0;
                    for (int i = 0; i < gridlob.Rows.Count; i++)
                    {

                        //finding checkbox in GridView
                        CheckBox cbx = (CheckBox)gridlob.Rows[i].FindControl("chkReimbursable");
                        //CheckBox not null
                        if (cbx != null)
                        {
                            //if CheckBox Checked

                            if (cbx.Checked)
                            {

                                j++;

                                //add your logic here.
                                //this is for example to get first column values of selected CheckBox
                                //string firstColumnValue = gridlob.Rows[i].Cells[0].Text;
                                //Response.Write(firstColumnValue);

                                if (j > 19)
                                {
                                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorAlert", "alert('Please select 19 lobs only');", true);
                                }


                            }
                        }

                    }



Please share your's information
Posted
Comments

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