Solved

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

Posted on 2007-11-26
2
1,596 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
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now