views:

20

answers:

1

Hi,

I'm very new to using Linq-to-SQL, that's why I'm asking this question. I've searched the site, but can't seem to figure out how to do this.

My problem is:

I have a database mapped with LINQ to SQL:

Table 1: PersonalTasks

TaskId
Header
[Content]
IsDone
CreatedDate

Table 2: Comments

CommentId
TaskId
UserId
Comment
CreatedDate

I have a repeater:

<asp:Repeater ID="PersonalTaskRepeater" runat="server">
   <ItemTemplate>
      <%#Eval("Header") %>
      <%# Eval("Content") %>
      Task done: <asp:CheckBox ID="IsDoneCheckBox" runat="server" Checked='<%#Eval("IsDone") %>' /><img src="Images/tick-circle.png" />

     Here i want to access the comment table, with the comments related to the taskID
   </ItemTemplate>
</asp:Repeater>

I've tried using: <%#Eval("Comment.Comment1")%> but that throws this error:

DataBinding: 'System.Data.Linq.EntitySet`1[[Assistr.Models.Comment, Assistr, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' does not contain a property with the name 'Comment'.

My code-behind:

var tasks = db.PersonalTasks.OrderBy(x => x.IsDone).ToList();
                PersonalTaskRepeater.DataSource = tasks;
                PersonalTaskRepeater.DataBind();

Do I need to use 2 repeaters to do what I want to do or? :)

Thanks in advance :)

//Mads

A: 

I believe If you wanted stuff in the same repeater, you would have to prep the datasource so that the data were effectively unioned and the same field names used. IF the 2 sets of data are different then why have them in the same repeater? What are you trying to do.

brumScouse
I'm not sure i'm doing this right, thats why i'm asking here :)
Mads Cortz Andreasen
I have this relation: PersonalTask.TaskId -> Comment.TaskId
Mads Cortz Andreasen
Hey mate not having a pop!.
brumScouse
You could try nesting your repeaters. That is for each row in the outer dataset (Personal Task), iterate over the corresponding related items in the inner dataset (Comment)
brumScouse