Bonjour,

Je débute en .NEt et je ne comprend pas comment accéder aux contrôles d'un gridview imbriqué dans un autre gridview.
Je m'explique. Sur ma page web en ASP.NET / VB.NET, j'ai un premier gridview qui m'affiche une liste de produits avec leur caractéristiques ....
A l'intérieur de ce gridview, pour chaque produit (chaque ligne), j'ai un autre gridview qui lui liste des tarifs liés à ce produit.

Pour mieux comprendre, j'ai ceci sur la page web produits.aspx :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
      <asp:GridView ID="ProdsView"
      CssClass="GammeViewStyle"
      AutoGenerateColumns="false"
      GridLines="Horizontal"
      onrowdatabound="ProdsView_RowDataBound"
      runat="server"
      cellpadding="0"
      cellspacing="0"
      ShowHeader="false">
      <columns>
      <asp:TemplateField ItemStyle-Width="100%" ItemStyle-HorizontalAlign="left" ItemStyle-CssClass="GammeBlocProduit">
      <itemtemplate>
     

     <asp:Label ID="LabelGammeTitreProduit" runat="server" Text="Désignation Article" />
      ....

          <asp:GridView ID="TarifsView"
          CssClass="GammeBlocTarifsView"
          AutoGenerateColumns="false"
          GridLines="Horizontal"
          onrowdatabound="TarifsView_RowDataBound"
          runat="server"
          cellpadding="0"
          cellspacing="0"
          ShowHeader="false" onselectedindexchanged="TarifsView_SelectedIndexChanged">
          <columns>
          <asp:TemplateField ItemStyle-Width="100%" ItemStyle-HorizontalAlign="left" ItemStyle-CssClass="GammeBlocTarifsView">
          <itemtemplate>
           

           <asp:Label ID="LabelTarif" runat="server" Text="Prix : XX.XX € TTC" CssClass="TexteTarif" />
           ....

          </itemtemplate>
          </asp:TemplateField>
          </columns>
          </asp:GridView>



      </itemtemplate>
      </asp:TemplateField>
      </columns>
      </asp:GridView>
Concernant le code behind de ma page produits.aspx.vb,
pour le premier Gridview (ProdsView) j'accède aux contrôles sans aucun problème, tout fonctionne comme ceci par exemple :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Protected Sub ProdsView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles ProdsView.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            
             Dim ProdDesignation As Label = CType(e.Row.FindControl("LabelGammeTitreProduit"), Label)
             Dim strProdDesignation As String = CStr(DataBinder.Eval(e.Row.DataItem, "ProdDesignation"))
             ProdDesignation.Text = strProdDesignation

             ' remplissage de mon second gridview
             Dim GridViewTarifs As GridView = CType(e.Row.FindControl("TarifsView"), GridView)
             Dim objProd As New Products
             Dim DtTarifsProds As DataSet = objProd.GetTarifsFromProduct(ProdId)
             GridViewTarifs.DataSource = DtTarifsProds
             GridViewTarifs.DataBind()


        End If 
End Sub
Par contre, pour le second gridview (TarifsView), impossible d'y accéder de la même manière.
Si je met :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7

Protected Sub TarifsView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles TarifsView.RowDataBound

...

End Sub
il me met en rouge TarifsView (voir dans le code ci-dessus) et me met :
La Claude Handles requiert une variable WithEvents définie dans le type conteneut ou l'un de ses types de base
Comment rajouter ce quelque chose dans le code de "ProdsView_RowDataBound()" ??? je ne vois pas du tout