I would like to use a data list for showing the usernames and their comments and attachments for each comment below the user name.
I have a user control ReviewListfor showing the comments and efiles in that. But I have error in this line (s.tblDraft.Comments) and an error below:
The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments
Please help. What is the problem?
private void Displayuser()
{
var reviews =
(from s in _DataContext.tblSends
from u in _DataContext.Users
where (s.DraftId == _Draftid) && (s.ToEmailId == u.ID)
orderby u.Name
select new
{
userid = u.ID,
username = u.Name,
comments =s.tblDraft.Comments,
w = s.tblDraft.Comments.SelectMany(q => q.CommentAttaches)
}).Distinct();
DataList1.DataSource = reviews;
DataList1.DataBind();
var theReview = reviews.Single();
DisplayReviews(theReview.comments, theReview.w);
}
private void DisplayReviews(IEnumerable<Comment> comments,
IEnumerable<CommentAttach> w)
{
ReviewList reviewList = (ReviewList)DataList1.FindControl("ReviewList1");
reviewList.Comments = comments;
reviewList.CommentAttachs = w;
reviewList.DataBind();
}
The type the compiler sees is
System.Collections.IEnumerablewhich is the non generic IEnumerable. You imported that namespace, so this is the type the compiler thinks you’re trying to use.The type you’re trying to use is
System.Collections.Generic.IEnumerable<T>. Add an import of that namespace and things should compile.