I have two tables. Post table and Follow table. Post table has all the posts of a user and Follow table has the list of user followed by a user.
Post Table
PostID UserID Post
1 2 TextOne
2 1 TextTwo
3 1 Text3
4 2 Text4
Follow Table
ID Following FollowedBy
1 2 1
2 3 1
And I have a list view.
<ItemTemplate >
Post:
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Post") %>' />
<br />
UserID:
<asp:Label ID="Label2" runat="server" Text='<%# Eval("UserID") %>' />
<br />
</ItemTemplate>
I want to show the posts of the user and the people who he are following. I wrote the following code.
int UserId = Convert.ToInt32(Session["User"]);
int[] OthersPosts = (from s in Data.Follow where s.FollowedBy == UserId) select s.Following1).ToArray();
foreach (int post in OthersPosts)
{
var DisplayPost = (from s in Data.Posts where s.UserID == post && s.UserID == UserId) select s).ToList();
ListViewPostTable.DataSourceID = "";
ListViewPostTable.DataSource = DisplayPost;
ListViewPostTable.DataBind();
}
But no data is displayed on the ListView?
I have checked the watch window for the value in DisplayPost variable, it says Enumeration yielded no results.