Click here to Skip to main content
15,905,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Day All,
I have this little issue with my Gridview.. if i check all the items it will send message but if i check only one item it will not send message unless I check the Item No One

see the code

C#
  foreach (GridViewRow row in GridView1.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {

                    CheckBox cb = (CheckBox)row.FindControl("Check");
                    if (cb.Checked == true)
                    {
                        if (cb != null && cb.Checked)
                        {
// a simple javascript that says Checked
    MyClass.MyAlert(this, "Checked", "123");
    }
                    }

  else
                    {
                        MyClass.MyAlert(this, "Not Checked", "123");
                        
                        return;
                    }
}
}

/*like i said before it worked perfectly fine if i check all the items, but if i check one items it will not work.... Am I missing something?.. Kindly Assist me

thanks for your valued time...i really do appreciate them
*/
Posted

1 solution

Not need of else part right,

As you checking condition, you will go further only for checked values, then what is the use of else part,

Remove else and try again..
 
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