ASP.Net repeater item.DataItem is null

Posted by mattgcon on Stack Overflow See other posts from Stack Overflow or by mattgcon
Published on 2011-01-10T16:49:24Z Indexed on 2011/01/10 16:53 UTC
Read the original article Hit count: 262

Filed under:
|
|
|

Within a webpage, upon loading, I fill a dataset with two table with a relation between those tables and then load the data into a repeater with a nested repeater. This can also occur after the user clicks on a button. The data gets loaded from a SQL database and the repeater datasource is set to the dataset after a postback. However, when ItemDataBound occurs the Item.Dataitem is always null.

Why would this occur?

below is my HTML repeater 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>

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about null