Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7457929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:23:05+00:00 2026-05-29T13:23:05+00:00

I get that error in my GetForumsByForumGroupID method where it selects the Forum object

  • 0

I get that error in my GetForumsByForumGroupID method where it selects the Forum object in my Linq statment. I haven’t had this error before so i don’t know what it is why I have it. I don’t even need the Forum object i just need the Title and ForumID properties but I don’t know how to return a anonymous object e.g.

var forums = (from x in db.Forums select new {ForumID = x.ForumID, Title = x.Title}).ToList();

Error in here. gets the selected forums passed on by dropdownlist

    public List<Forum> GetForumsByForumGroupID(int ForumGroupID)
    {
        using (CMSEntities db = new CMSEntities())
        {
            List<Forum> forums = (from x in db.Forums where x.ParentID == ForumGroupID select 
                              new Forum(x.ForumID, "",DateTime.Now, x.Title, "", 0, x.Importance, false, "",
                                  "", "", DateTime.Now, true, "", 0, "", DateTime.Now, "", 0, 0, "", 0)).ToList<Forum>();
            return forums;
        }
    }

Markup:

<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true"   AutoPostBack="true" 
    DataSourceID="ObjectDataSource1" DataTextField="Key" 
    DataValueField="Value">

</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
    SelectMethod="GetDisplayForumGroups" TypeName="CMS.Framework.Forums">
</asp:ObjectDataSource>


<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
    DataSourceID="ObjectDataSource2">
    <Columns>
        <asp:BoundField DataField="ForumID" HeaderText="ForumID" 
            SortExpression="ForumID" />
        <asp:BoundField DataField="AddedBy" HeaderText="AddedBy" 
            SortExpression="AddedBy" />
        <asp:BoundField DataField="AddedDate" HeaderText="AddedDate" 
            SortExpression="AddedDate" />
        <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="ParentID" HeaderText="ParentID" 
            SortExpression="ParentID" />
        <asp:BoundField DataField="Importance" HeaderText="Importance" 
            SortExpression="Importance" />
        <asp:CheckBoxField DataField="Moderated" HeaderText="Moderated" 
            SortExpression="Moderated" />
        <asp:BoundField DataField="Url" HeaderText="Url" SortExpression="Url" />
        <asp:BoundField DataField="ImageUrl" HeaderText="ImageUrl" 
            SortExpression="ImageUrl" />
        <asp:BoundField DataField="UpdatedBy" HeaderText="UpdatedBy" 
            SortExpression="UpdatedBy" />
        <asp:BoundField DataField="UpdatedDate" HeaderText="UpdatedDate" 
            SortExpression="UpdatedDate" />
        <asp:CheckBoxField DataField="Active" HeaderText="Active" 
            SortExpression="Active" />
        <asp:BoundField DataField="ForumGroup" HeaderText="ForumGroup" 
            SortExpression="ForumGroup" />
        <asp:BoundField DataField="ThreadCount" HeaderText="ThreadCount" 
            SortExpression="ThreadCount" />
        <asp:BoundField DataField="LastPostBy" HeaderText="LastPostBy" 
            SortExpression="LastPostBy" />
        <asp:BoundField DataField="LastPostDate" HeaderText="LastPostDate" 
            SortExpression="LastPostDate" />
        <asp:BoundField DataField="LastPostTitle" HeaderText="LastPostTitle" 
            SortExpression="LastPostTitle" />
        <asp:BoundField DataField="LastPostID" HeaderText="LastPostID" 
            SortExpression="LastPostID" />
        <asp:BoundField DataField="ThreadID" HeaderText="ThreadID" 
            SortExpression="ThreadID" />
        <asp:BoundField DataField="ThreadTitle" HeaderText="ThreadTitle" 
            SortExpression="ThreadTitle" />
        <asp:BoundField DataField="ReplyCount" HeaderText="ReplyCount" 
            SortExpression="ReplyCount" />
    </Columns>
</asp:GridView>

<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
    SelectMethod="GetForumsByForumGroupID" TypeName="CMS.Framework.Forums">
    <SelectParameters>
        <asp:ControlParameter ControlID="DropDownList1" PropertyName="SelectedValue" 
        Type="Int32" Name="ForumGroupID" /> 
    </SelectParameters>
</asp:ObjectDataSource>

Updated:

    public   GetForumsByForumGroupID(int ForumGroupID)
    {
        using (CMSEntities db = new CMSEntities())
        {
            var forums = (from x in db.Forums where x.ParentID == ForumGroupID select 
                              x).ToList();
            return forums;
        }
    }

Can’t do this either

    public List<Forum>  GetForumsByForumGroupID(int ForumGroupID)
    {
        using (CMSEntities db = new CMSEntities())
        {
            List<Forum> formus = (from x in db.Forums where x.ParentID == ForumGroupID select 
                              x).ToList<Forum>();
            return forums;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:23:06+00:00Added an answer on May 29, 2026 at 1:23 pm

    Why are you creating new Forum objects in the first place? Unless there’s a good reason not to, just do select x.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get an error that says Parse error: syntax error, unexpected T_PRIVATE in E:\PortableApps\xampp\htdocs\SN\AC\ACclass.php
Running into a problem where on certain servers we get an error that the
while executing the following query, i get an error that there's an error in
I want to rename a database, but keep getting the error that 'couldn't get
When I try to do that I get the error Changed to 64-bit applications
I have a website that I get the below error on whenever I navigate
When I try to do that I get the following error: Changes to 64-bit
I am getting the following error when I get to the line that invokes
When running a Python program that reads from stdin, I get the following error:
How do I unit test my code that has LTS Datacontext. I get error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.