Solved

Find Gridview within a Gridview/ItemTemplate within Table within Panel within CollapsablePanel

Posted on 2010-09-05
2
606 Views
Last Modified: 2013-11-08
Hi,

I am in the process of designing forms and have not bound my grids yet, but can display 1 row of my grids using a simple procedure.
All of my grids are available in code behind except this one that is embedded into one of my grids.
I have tried the findcontrol and it always returns nothing.
The hierarchy of the form is
CollapsablePanel
   Panel
     Table
        Gridview
            ItemTemplate
               GridView       ***** Can't find this one

I am trying to find it in the Parent Grid Load Event


Protected Sub grdServiceDetails_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdServiceDetails.Load

          CheckGrid(Me.grdServiceDetails)

          Dim grd As GridView = DirectCast(grdServiceDetails.FindControl("grdProductsUsed"), GridView)

          If Not grd Is Nothing Then

               CheckGrid(grd)

          End If

     End Sub

Open in new window

0
Comment
Question by:Sheritlw
2 Comments
 
LVL 5

Accepted Solution

by:
karthitron earned 500 total points
ID: 33609058
You want to access the grid view which resides in another grid view's Item Template. Then instead of directly getting the inner grid from parent grid, you have to iterate through each row in parent grid and find the inner grid in each row or each row's specific cell (for demonstating I used cell index as zero, you can specify the valid cell index otherwise simply you can use row object instead of cell object). Following is sample code:
Protected Sub GridView1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.Load

        For Each gvr As GridViewRow In GridView1.Rows

            Dim grd As GridView = DirectCast(gvr.FindControl("grdProductsUsed"), GridView)

            'Dim grd As GridView = DirectCast(gvr.Cells[0].FindControl(""), GridView)

            If Not grd Is Nothing Then

                CheckGrid(grd)

            End If

        Next

    End Sub

Open in new window

0
 

Author Closing Comment

by:Sheritlw
ID: 33613252
Thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

16 Experts available now in Live!

Get 1:1 Help Now