Click here to Skip to main content
11,487,979 members (80,817 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
<asp:GridView ID="grdnewUser" runat="server" AutoGenerateColumns="false" GridLines="None">
                                                        <ul class="last_post">
                                                                <asp:Label ID="lblDateposted" Text='<%#Eval("DatePosted") %>' Font-Underline="false"
                                                                <asp:Label ID="Label1" Text='<%#Eval("QuestionTitle") %>' Font-Underline="false"
                                                                <asp:LinkButton ID="lnkUsername" runat="server" Text='<%#Eval("UserName") %>' Font-Underline="false"></asp:LinkButton>

public void bindLastPost()
            ArrayList a = new ArrayList();
            foreach (GridViewRow row in grdForum.Rows)
                int quesID = Convert.ToInt16(grdForum.DataKeys[row.RowIndex].Values["TechID"].ToString());
                var lastpost = db.tblQuestions.Where(u => u.TechID.Equals(quesID)).OrderByDescending(u => u.DatePosted).Take(1).FirstOrDefault();
                a.Add(new Results { DatePosted = lastpost.DatePosted, QuestionTitle = lastpost.QuestionTitle, UserName = lastpost.UserName });
            var query = from Results student in a
                        select student;
            grdnewUser.DataSource = query.ToList();

DataBinding: 'ForumsApp.Main1+Results' does not contain a property with the name 'DatePosted'.
Posted 1-Feb-13 21:20pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please Change DatePosted Field In Table and Grid Automatically Solve this Error.
Dorababu743 at 2-Feb-13 3:19am
Change to what

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,308
1 OriginalGriff 8,352
2 Sascha Lefèvre 3,334
3 Maciej Los 2,956
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100