views:

208

answers:

0

I have 3 tables in my DB.
I implemented a N-N relation using "AccountAccessRight" Table as a junction Table.
So "Account" Table has 1-N relation with "AccountAccessRight" and "AccountAccessRight" has N-1 Relation to "NextOfKin" Table.
Iwant to list every Account and List every NextOfKins of each account In "Repeater1".
Here is DB Diagram: alt text

So I wrote this Code:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
        <HeaderTemplate>
        </HeaderTemplate>
        <ItemTemplate>
            <div style="clear: both;">
                <img style="float: right;" alt="" src="./img/account.png" />
                <a href='<%# Eval("AccountUrl")%>'>
                    <%# Eval("AccountTitle")%>
                </a>
                <br />
                <span>نام کاربري:</span><%# Eval("AccountUsername")%><br />
                <asp:Repeater ID="Repeater2" DataSource="<%# ((aspnet_AccountTable)(Container.DataItem)).aspnet_AccountAccessRights %>"
                    runat="server">
                    <ItemTemplate>
                        <asp:Repeater ID="Repeater3" DataSource="<%# ((aspnet_AccountAccessRight)(Container.DataItem)).aspnet_NextOfKinTable %>"
                            runat="server">
                            <HeaderTemplate>
                                <hr />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <span>وارث يا وارثان:</span>
                                <div>
                                    <a href='<%# Eval("NoKId","./FullInfo.aspx?Mode=view&nok={0}")%>'>
                                        <%# Eval("Firstname")%>
                                        <%# Eval("Lastname")%>
                                    </a>,
                                </div>
                            </ItemTemplate>
                            <FooterTemplate>
                                <hr />
                            </FooterTemplate>
                        </asp:Repeater>
                    </ItemTemplate>
                </asp:Repeater>
                <%--<span>وارث(ان) حساب:</span><%# Eval("Relationship")%><br />--%>
                <%--<span>نام وارث:</span><%# Eval("FirstName") %>&nbsp;<%# Eval("LastName") %>--%>
            </div>
        </ItemTemplate>
    </asp:Repeater>

Look at repeater2 and 3 DataSource!
There is an Exception when Comiling Repeater3.
Notice That "objectdatasource1" just projects all aspnet_accountTable:

...
from acc in db.aspnet_AccountTable
select acc;
...

Can You Help Me?

ADDED: Here is Full Exception Detial:

System.ArgumentException was unhandled by user code
  Message="An invalid data source is being used for Repeater3. A valid data source must implement either IListSource or IEnumerable."
  Source="System.Web"
  StackTrace:
       at System.Web.UI.WebControls.Repeater.set_DataSource(Object value)
       at ASP.user_accounts_default_aspx.__DataBinding__control9(Object sender, EventArgs e) in g:\MyProjects\ASP.net Projects\After Dyeing\WebSite\User\Accounts\Default.aspx:line 30
       at System.Web.UI.Control.OnDataBinding(EventArgs e)
       at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
       at System.Web.UI.WebControls.Repeater.DataBind()
       at System.Web.UI.Control.DataBindChildren()
  InnerException: