Data Entry Validation

  • Thread starter Thread starter Jeremy S
  • Start date Start date
J

Jeremy S

In a Web Forms application I present users with a list of items - each of
which the user is to assign to a grid. The grid is N rows by 3 columns.

The users enter the desired target cell for each list item by specifying two
integer values - one for the row number and the other for the column number
of the target cell.

When users submit the form for processing I need to validate that the
following are all true:
Please note that I can tackle 1 and 2 on my own as well as test for data
type, etc (will use RegEx). What I'd appreciate suggestions is how to
accomplish #3:

1. No value specified for RowNumber is larger than the total possible number
of rows.
2. Each value for ColumnNumber is 1, 2, or 3 (never zero, and never larger
than 3)
3. No cell is specified more than once (i.e., every combination of RowNumber
and ColumnNumber entered must be unique.


While this is a Web application, I'll be processing this on the server
during a postback.

Thanks.
 
umm ...

You can use a 2 dim array for rows and columns with all cell initialized to
false, and once a use specify a row-column combination you can mark the
corresponding cell in the array as true. like this:

bool[,] cells = new bool[N,3]; // by default, all will initialize to false;

when i use specify a combination of row (r) and column (c), do simple check:
if (!cells[r,c])
{
// process this combination in the grid
// set the cell array to true
cells[r,c] = true;
}

I hope this solve your problem
 
Thanks! That looks simple enough. I'll give it a whirl.


Ahmed Ghozzy said:
umm ...

You can use a 2 dim array for rows and columns with all cell initialized
to
false, and once a use specify a row-column combination you can mark the
corresponding cell in the array as true. like this:

bool[,] cells = new bool[N,3]; // by default, all will initialize to
false;

when i use specify a combination of row (r) and column (c), do simple
check:
if (!cells[r,c])
{
// process this combination in the grid
// set the cell array to true
cells[r,c] = true;
}

I hope this solve your problem
--
Ahmed Ghozzy


Jeremy S said:
In a Web Forms application I present users with a list of items - each of
which the user is to assign to a grid. The grid is N rows by 3 columns.

The users enter the desired target cell for each list item by specifying
two
integer values - one for the row number and the other for the column
number
of the target cell.

When users submit the form for processing I need to validate that the
following are all true:
Please note that I can tackle 1 and 2 on my own as well as test for data
type, etc (will use RegEx). What I'd appreciate suggestions is how to
accomplish #3:

1. No value specified for RowNumber is larger than the total possible
number
of rows.
2. Each value for ColumnNumber is 1, 2, or 3 (never zero, and never
larger
than 3)
3. No cell is specified more than once (i.e., every combination of
RowNumber
and ColumnNumber entered must be unique.


While this is a Web application, I'll be processing this on the server
during a postback.

Thanks.
 
Back
Top