troubleshooting Question

nested gridview findcontrol not working

Avatar of kevlause
kevlause asked on
5 Comments1 Solution1763 ViewsLast Modified:
I have a nested gridview that I need to sum up the values of a cell in and set a label in the parent gridview based on that sum. the below code I think should do that but gridview2 always comes back as nothing. What am I missing? Why can't I use findcontrol to find gridview2?

I tried the code in gridview1.databound and in page load and still nothing...

        Dim count As Integer = 0
        Dim GridView2 As GridView
        Dim qtyshippedLabel As Label
        For Each row As GridViewRow In GridView1.Rows
            qtyshippedLabel = row.FindControl("qtyshippedLabel")
            GridView2 = row.FindControl("GridView2")
            If GridView2 IsNot Nothing Then
                For Each r As GridViewRow In GridView2.Rows
                    count = count + r.Cells(0).Text
            End If
            qtyshippedLabel.Text = count
            count = 0
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros