• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 633
  • Last Modified:

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

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
Sheritlw
Asked:
Sheritlw
1 Solution
 
karthitronCommented:
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
 
SheritlwAuthor Commented:
Thank you
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now