Link to home
Start Free TrialLog in
Avatar of jean4spa
jean4spa

asked on

Simple Nested repeater

Hi,

I'm trying to create a simple nested repeater following the tutorial on ASP.NET> Nested Data Web Controls.
But I'm having problems. While executing I get an error System.NullReferenceException: Object reference not set to an instance of an object.

, In debugmode I see that ObjectDataSource2 = Nothing.

Can somebody give me advise how to take things further?
here is my code:
Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
        If e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item Then
            Dim Rol As planning.aspnet_Roles_GetAllRolesRow = CType(CType(e.Item.DataItem, System.Data.DataRowView).Row, planning.aspnet_Roles_GetAllRolesRow)
            ObjectDataSource2.SelectParameters("ApplicationName").DefaultValue = "MyApplication"
            ObjectDataSource2.SelectParameters("RoleName").DefaultValue = Rol.RoleName.ToString
 
        End If
    End Sub
 
 
And in the actual page:
 
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">    
    <ItemTemplate>  
    <br /><br />
    <asp:Label runat="server" Text='<%# Eval("RoleName") %>'></asp:Label>    
        <asp:Repeater ID="Repeater2" runat="server" DataSourceID="ObjectDataSource2">
        <ItemTemplate >
            <asp:Label runat="server" Text='<%# Eval("UserName") %>'></asp:Label><br />
        </ItemTemplate>
        </asp:Repeater>
    </ItemTemplate>  
        </asp:Repeater>
  <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
        TypeName="planningTableAdapters.aspnet_Roles_GetAllRolesTableAdapter">
        <SelectParameters>
            <asp:Parameter DefaultValue="MyApplication" Name="ApplicationName" 
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
 
 
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
        TypeName="planningTableAdapters.aspnet_UsersInRoles_GetUsersInRolesTableAdapter">
        <SelectParameters>
            <asp:Parameter DefaultValue="MyApplication" Name="ApplicationName" 
                Type="String" />
            <asp:Parameter DefaultValue="" Name="RoleName" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David Robitaille
David Robitaille
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jean4spa
jean4spa

ASKER

Thanks.