?
Solved

How to access dynamically created controls nested in an asp.net table

Posted on 2007-11-26
2
Medium Priority
?
1,619 Views
Last Modified: 2013-11-26
I have an asp.net  table <asp:table> </asp:table>, that is created dynamically when the user clicks a button.  the table has a row added to it with each click.  I have the data posting back correctly, and now need to total the values.  I know I can use the find control option, however, how do I access the data inside the table?  I have the code listed in a snippet below.

But it is only finding HeaderRows, and TableRows.  I know there is a TableRows.{cellcollection name of some sort), but am unaware as to how to obtain it.  
What I ultimately need:
The rows consist of :
QTY / ITEM / Amount / Extended cost(Amount * Qty)

The find control should search through the table and find the QTY amount, place it into an array.  Find the Amount textbox, place that into an array.  Once both arrays are filled I will create a function to add them appropriately...which is simple...it is just getting the data from the table row that I need help with.
For start = 1 To count
            For Each ctr In table.Rows
                If TypeOf ctr Is TextBox Then
                    If CType(ctr, TextBox).ID.ToString = "txtQuantity" & start.ToString Then
                        Select Case CType(ctr, TextBox).Text
                            Case Is = ""
                                qty = 0
                                Quantities(start - 1) = "0.00"
                            Case Is <> ""
                                Quantities(start - 1) = CType(ctr, TextBox).Text
                        End Select
                    ElseIf CType(ctr, TextBox).ID.ToString = "txtItemCost" & start.ToString Then
                        Select Case CType(ctr, TextBox).Text
                            Case Is = ""
                                ttl = 0
                                Amounts(start - 1) = "0.00"
                            Case Is <> ""
                                Amounts(start - 1) = CType(ctr, TextBox).Text
                        End Select
                    End If
                Else
                End If
            Next
        Next

Open in new window

0
Comment
Question by:JaCrews
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 20353416
Are you using FindControl from the page or from the table?  FindControl only works for calls at the lowest naming container level, unless you program a recursive search function.

Bob
0
 

Author Comment

by:JaCrews
ID: 20364929
Ended up solving the question myself....with the recursive function, so..since the points are unlimited, and it was in effect the right answer....Congrats Learned One!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question