Home All Groups Group Topic Archive Search About
Author
31 Jan 2005 12:36 PM
et
I have a web form with several grids on it, and a procedure that cycles
through each grid to do a number of tasks, using for next, and am getting a
"Specified cast is not valid" error when I attempted to put the grid names
in an arraylist.

For sample purposes, we'll name the grids grid1, grid2, grid3.

when I manually set each grid, it works fine:

        dg = grid1
        GetData(dg)
        dg = grid2
        GetData(dg)
        dg=grid3
        GetData(dg)

but when I attempted to put the grids in an arraylist, I get the cast error:

    arrGrids.add("grid1")
    arrGrids.add("grid2")
    arrGrids.add("grid3")

    for i = 0 to arrGrids.Count-1
        dg = ctype(arrGrids(i), DataGrid)
        GetData(dg)
    next

How else can I do this?  tia

Author
31 Jan 2005 1:16 PM
Eliyahu Goldin
arrGrids.add("grid1") adds a string "grid1".

arrGrids.add(grid1) will add the object grid1.

Eliyahu

Show quoteHide quote
"et" <eagletender2***@yahoo.com> wrote in message
news:%23re9sR5BFHA.2984@TK2MSFTNGP11.phx.gbl...
> I have a web form with several grids on it, and a procedure that cycles
> through each grid to do a number of tasks, using for next, and am getting
a
> "Specified cast is not valid" error when I attempted to put the grid names
> in an arraylist.
>
> For sample purposes, we'll name the grids grid1, grid2, grid3.
>
> when I manually set each grid, it works fine:
>
>         dg = grid1
>         GetData(dg)
>         dg = grid2
>         GetData(dg)
>         dg=grid3
>         GetData(dg)
>
> but when I attempted to put the grids in an arraylist, I get the cast
error:
>
>     arrGrids.add("grid1")
>     arrGrids.add("grid2")
>     arrGrids.add("grid3")
>
>     for i = 0 to arrGrids.Count-1
>         dg = ctype(arrGrids(i), DataGrid)
>         GetData(dg)
>     next
>
> How else can I do this?  tia
>
>
>
>
>
Author
31 Jan 2005 3:00 PM
et
Don't know why I didn't catch that one, thanks!  Must be a Monday.  That did
the trick.
Show quoteHide quote
"Eliyahu Goldin" <removemeegol***@monarchmed.com> wrote in message
news:O6srna5BFHA.4004@tk2msftngp13.phx.gbl...
> arrGrids.add("grid1") adds a string "grid1".
>
> arrGrids.add(grid1) will add the object grid1.
>
> Eliyahu
>
> "et" <eagletender2***@yahoo.com> wrote in message
> news:%23re9sR5BFHA.2984@TK2MSFTNGP11.phx.gbl...
>> I have a web form with several grids on it, and a procedure that cycles
>> through each grid to do a number of tasks, using for next, and am getting
> a
>> "Specified cast is not valid" error when I attempted to put the grid
>> names
>> in an arraylist.
>>
>> For sample purposes, we'll name the grids grid1, grid2, grid3.
>>
>> when I manually set each grid, it works fine:
>>
>>         dg = grid1
>>         GetData(dg)
>>         dg = grid2
>>         GetData(dg)
>>         dg=grid3
>>         GetData(dg)
>>
>> but when I attempted to put the grids in an arraylist, I get the cast
> error:
>>
>>     arrGrids.add("grid1")
>>     arrGrids.add("grid2")
>>     arrGrids.add("grid3")
>>
>>     for i = 0 to arrGrids.Count-1
>>         dg = ctype(arrGrids(i), DataGrid)
>>         GetData(dg)
>>     next
>>
>> How else can I do this?  tia
>>
>>
>>
>>
>>
>
>