Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Checkbox checked state

Posted on 2013-06-18
8
Medium Priority
?
386 Views
Last Modified: 2013-06-19
Hi,

How can I stop the loop and display some message if user has not selected any check box in a grid view control?

Thanks

ayha
0
Comment
Question by:ayha1999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39256874
Stop what loop?
0
 
LVL 7

Author Comment

by:ayha1999
ID: 39256918
I tried the following but not working.  even if user not selected an item it is not displaying the message.

 foreach (GridViewRow row in gvFiles.Rows)
        {
            CheckBox chkSelect = ((CheckBox)row.FindControl("chkBxSelect"));
            if (chkSelect.Checked == false)
            {
                i += 1;
                //break;
            }

            if (i == 0)
            {
                lblmsg.Text = "Please select an item.";
                proceed = false;
            }

        }
0
 
LVL 58

Expert Comment

by:Gary
ID: 39257004
Where are you setting i to be equal to 0
0
PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

 
LVL 7

Author Comment

by:ayha1999
ID: 39257010
Outside of the loop

 int i = 0;
        foreach (GridViewRow row in gvSTLFiles.Rows)
        {
0
 
LVL 58

Expert Comment

by:Gary
ID: 39257022
Your logic doesn't  make sense, the first condition you are saying if not checked then increment i which means the second condition is never met if the checkbox is not checked
0
 
LVL 7

Author Comment

by:ayha1999
ID: 39257083
can you give a me a solution?
0
 
LVL 58

Accepted Solution

by:
Gary earned 600 total points
ID: 39257109
foreach (GridViewRow row in gvFiles.Rows)
        {
            CheckBox chkSelect = ((CheckBox)row.FindControl("chkBxSelect"));
            if (chkSelect.Checked == true)
            {
                i = 1;
                break;
            }
        }


            if (i == 0)
            {
                lblmsg.Text = "Please select an item.";
                proceed = false;
            }
0
 
LVL 7

Author Closing Comment

by:ayha1999
ID: 39258703
Thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question