473,503 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Web App: If statment based on table values

55 New Member
Hi hope anyone can help me on this:

I am creating a table of values in code that has one row and holds a value in each cell, that value could be 'Y' or 'N'. At times it could be 3 values or it could be 4 or 5 the number differs so what my question is:

How can I create an if statement to say that if all values in the created table are all 'Y' then run some code??

Thanks in advance.
Nov 28 '08 #1
2 905
nukefusion
221 Recognized Expert New Member
Hi,
You don't explain much about what object your are storing this table of values in. Is it a simple array?

An easy way would be to loop through all the cells on this row performing a check on each cell as you go. If a cell does not satisfy the condition set a flag stating that the check has failed. After you've iterated all cells, take action accordingly:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.     bool shouldRunCode = true;
  4.     foreach (Cell cell in row.Cells)
  5.     {
  6.         if (cell.Value != "Y") shouldRunCode = false;
  7.     }
  8.     if (shouldRunCode)
  9.     {
  10.          // No cells are "N" - Run your code here
  11.     }
  12.  
  13.  
Nov 28 '08 #2
dmj07
55 New Member
Ah thats exactly what I was after!! Thankyou very much :)!!
Nov 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1863
by: Dyslexic Fingars | last post by:
Warning I'm new to anything other than basic SQL so this 'might' seem like a daft question. My problem is - I've have two tables one hold's photo details and is called 'PhotoTable' it is linked...
1
1874
by: Nothing | last post by:
I am trying to use the sql INSERT INTO statement to add a new record. This is the SQL statement: sql = "INSERT INTO tblpatients(bbid, patientname, orderdate, ordertime, mrnumber, sex, age,...
0
2671
by: Janning Vygen | last post by:
Hi, i have a question about how to handle postgresql constraint errors in the client app. I found some mails in the archive about it, too. But i have still so many questions about how to do it,...
2
1604
by: Denis Correard | last post by:
I have an application that create an insert statment on the fly (it would be to complex to create stored procedures for all senarios) like: insert into Table (field1, field2,field3 ,field4 ) VALUES...
2
1360
by: Grub | last post by:
Hi Yall... This is my objective: I want the following snip of code to insert 2 values into table 'Failures'. The first value is based on a string that a user would type into a combo box. If...
5
3202
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
1
1573
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
2
2843
by: rshivaraman | last post by:
CREATE TABLE RS_A(ColA char(1), ColB varchar(10)) INSERT INTO RS_A VALUES ('S', 'shakespeare') INSERT INTO RS_A VALUES ('B', 'shakespeare') INSERT INTO RS_A VALUES ('P', 'shakespeare') ...
14
1334
by: thetaamommy | last post by:
CREATE Table CO(CustID int, OfficerSID varchar(10), OfficerRank tinyint) Insert Into CO VALUES (1, 'KURT', 1) Insert Into CO VALUES (1, 'ALEX', 2) Insert Into CO
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.