ASP.Net répétition de l'élément.DataItem est null

À l'intérieur d'une page web, une fois le chargement, j'remplir un dataset avec deux table avec une relation entre les tables, puis charger les données dans un répéteur avec un imbriquée répéteur. Cela peut également se produire après que l'utilisateur clique sur un bouton. Les données sont chargées à partir d'une base de données SQL et le répéteur source de données est définie à l'ensemble de données après une publication. Toutefois, lorsque ItemDataBound se produit l'Élément.Dataitem est toujours null.

Pourquoi?

Ici est la databind code:

        this.rptCustomSpaList.DataSource = ds;
        this.rptCustomSpaList.DataBind();

Ici est la ItemDataBound code:

        RepeaterItem item = e.Item; 

        Repeater ChildRepeater = (Repeater)item.FindControl("rptCustomSpaItem");
        DataRowView dv = e.Item.DataItem as DataRowView;
        ChildRepeater.DataSource = dv.CreateChildView("sparelation");
        ChildRepeater.DataBind();

ci-dessous mon code HTML répéteur code

<asp:Repeater ID="rptCustomSpaList" runat="server" 
onitemdatabound="rptCustomSpaList_ItemDataBound">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td><asp:Label ID="Label3" runat="server" Text="Spa Series:"></asp:Label></td>
<td><asp:Label ID="Label4" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "SPASERIESVALUE") %>'></asp:Label></td>
</tr>
<tr>
<td><asp:Label ID="Label5" runat="server" Text="Spa Model:"></asp:Label></td>
<td><asp:Label ID="Label6" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "SPAMODELVALUE") %>'></asp:Label></td>
</tr>
<tr>
<td><asp:Label ID="Label9" runat="server" Text="Acrylic Color:"></asp:Label></td>
<td><asp:Label ID="Label10" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ACRYLICCOLORVALUE") %>'></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="Label11" runat="server" Text="Cabinet Color:"></asp:Label>
</td>
<td>
<asp:Label ID="Label12" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CABPANCOLORVALUE") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label17" runat="server" Text="Cabinet Type:"></asp:Label>
</td>
<td>
<asp:Label ID="Label18" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CABINETVALUE") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label13" runat="server" Text="Cover Color:"></asp:Label>
</td>
<td>
<asp:Label ID="Label14" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "COVERCOLORVALUE") %>'></asp:Label>
</td>
</tr>
</table>
<asp:Label ID="Label15" runat="server" Text="Options:"></asp:Label>
<asp:Repeater ID="rptCustomSpaItem" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "PROPERTY") %>'></asp:Label>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "VALUE") %>'></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<table>
<tr>
<td style="padding-top:15px;padding-bottom:30px;">
<asp:Label ID="Label7" runat="server" Text="Configured Price:"></asp:Label>
</td>
<td style="padding-top:15px;padding-bottom:30px;">
<asp:Label ID="Label8" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "SPAVALUEVALUE") %>'></asp:Label>
</td>
</tr>
</table>
<asp:Label ID="Label16" runat="server" Text="------"></asp:Label>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater>
que fait votre code ressemble?

OriginalL'auteur mattgcon | 2011-01-10