Re: Creating variables in a loop!



Mark, thanks for the response, I appreciate it.

It appears to work, the only thing I'm a little bit confused on is how I
retrieve the information (the boolean checked or not checked) back from the
variable if the variable is in fact the same for each one?

Any hints on how I might be able to retrieve the boolean state of each of
them after the grid / table has already been built?


Thanks!!!

Todd

"Mark Fitzpatrick" wrote:

No. It also wouldn't do much good as a variable is only alive for the scope
of the loop and doesn't exist outside it. Keep in mind, you are creating an
object here, specifically object inherited from a webcontrol object. That
means you have a property available to you that you can set the ID of the
resultant control. The tmCell.ID property would allow you to set the name of
the control. You may also want to set the AccessKey property as well. Try
playing with this concept a bit as even if you could alter the name of the
variable in the loop, it doesn't do you any good as that reference is
useless the second you iterate through the loop again, or after the loop
completes.


--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Todd Jaspers" <ToddJaspers@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A6D24909-8BE9-4AF3-916E-F12B938AD29A@xxxxxxxxxxxxxxxx
Hey guys,

Is there ANY way to accomplish this: (see below)? Basically, I want
to
have a loop (a < 3 is just for testing purposes, it will be an
underermined
amount). In this loop, I want to be able to create a new cell each time.
In
this cell, I want the variable name to change. Is this at ALL possible?
I've
never been able to figure this out in some of the other languages.

Any help would GREATLY be appreciated.


TableRow tmRow = new TableRow();
tblCreditCards.Rows.Add(tmRow);
int a = 0;
while (a < 3)
{
TableCell tmCell = new TableCell();
tmRow.Cells.Add(tmCell);
CheckBox chk = new CheckBox();
chk.Text = "This is a test for #" + a;
tmCell.Controls.Add(chk);
tmRow.Cells.Add(tmCell);
a++;
}

would it be something like this???

TableRow tmRow = new TableRow();
tblCreditCards.Rows.Add(tmRow);
int a = 0;
while (a < 3)
{
TableCell tmCell#a# = new TableCell();
tmRow.Cells.Add(tmCell#a#);
CheckBox chk#a# = new CheckBox();
chk#a#.Text = "This is a test for #" + a;
tmCell#a#.Controls.Add(chk);
tmRow#a#.Cells.Add(tmCell#a#);
a++;
}


Thanks!!!



.



Relevant Pages

  • Re: Hourglass wont display while code executes
    ... It doesn't wait for the subform to retrieve the records. ... to assigning SQL to the RecordSource, then create a loop that will run until ... Dim dteLoop As Date, intWait As Integer ... criteria generated by passing other values in controls through specialized ...
    (microsoft.public.access.forms)
  • Re: Set A Parameter Without Redirecting A Page?
    ... Mark Fitzpatrick wrote: ... using AJAX because then you wouldn't be posting back the whole page. ... I am trying to set a parameter - ResponseId = 4 inside a while loop. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Creating variables in a loop!
    ... Any hints on how I might be able to retrieve the boolean state of each ... You can retrieve them the same way: loop through the Cells collection ... and find the first control inside that cell. ... It's "just" a Control, so you will have to cast it to a CheckBox. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: vbscript logon script getting return data from sql sp
    ... > One way to retrieve values from a stored procedure is with a Recordset ... then the Do Until adoRecordset.EOF loop above loops ...
    (microsoft.public.scripting.vbscript)
  • Re: Arrange them [ updated ]
    ... This I loop also gives the two variables X and X1 there ... 50 REM I value at it's greatest equals the length of the string. ... 240 REM The only way to retrieve the original A$ before ... you a little information about the original string (specifically, ...
    (sci.math)