Click here to Skip to main content
15,911,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Check whether the Grid View Check box all are Unchecked in asp .net

There is a check box in a grid view where we have to click on a check box if not check and Click on a Submit Button then message should come Please Click on a Check Box First !!!!
Posted
Updated 29-Sep-14 23:59pm
v2
Comments
Thanks7872 30-Sep-14 5:50am    
This is not at all a question. We can not read your mind. You have to post the code you have implemented and describe issues with that code.

On Click Event Do This

C#
foreach(Gridviewrow gvr in Gridview1.Rows)
 {
     if(((CheckBox)gvr.findcontrol("CheckBox1")).Checked == false)
     {
        //do something
     }
     else
     {
        //do something
     }
 }
 
Share this answer
 
You can validate this in client side like this

if i click on that checkbox i want that corrsponding ID that' why am saving that id in hidden field. if you did't select any check box the checkedIDs length will be zero

$('[id^="MainContent_rptrFollowup_chkSelect_"]').live("click", CheckCheckBox);

       var checkedIDs = "";
       function CheckCheckBox() {
           var tempid = $(this)[0].id.split('_')[parseInt($(this)[0].id.split('_').length) - 1];
           if ($(this).is(":checked")) {
               if (checkedIDs.search($("#MainContent_rptrFollowup_hdnchkPatientAppointmentID_" + tempid).val()) < 0) {
                   checkedIDs += $("#MainContent_rptrFollowup_hdnchkPatientAppointmentID_" + tempid).val() + ":";
               }
           }
           else {
               if (checkedIDs.search($("#MainContent_rptrFollowup_hdnchkPatientAppointmentID_" + tempid).val()) >= 0) {
                   checkedIDs = checkedIDs.replace($("#MainContent_rptrFollowup_hdnchkPatientAppointmentID_" + tempid).val() + ":", '');
               }
           }
       }

       function chekCkeckBox() {
           var isChecked = false;
           if (checkedIDs.length > 0) {
               $('#MainContent_hdnChkSendMail').val(checkedIDs);
               isChecked = true;
           }
           if (isChecked)
               return true;
           else {
               AlertDialog('You are required to select at least one item from the list to send email.', "eMeditime - Send Mail");
               return false;
           }
           return true;
       }
 
Share this answer
 
v3

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