Casting a grid

E

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
 
E

Eliyahu Goldin

arrGrids.add("grid1") adds a string "grid1".

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

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top