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 6587377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:54:34+00:00 2026-05-25T16:54:34+00:00

I have an entity class Person { public int Age{get;set;} public string Name{get;set;} public

  • 0

I have an entity

class Person
{
public int Age{get;set;}
public string Name{get;set;}
public Department Dept{get;set;}
}

class Department
{
public int DeptId{get;set;}
public string DeptName{get;set}
}

Now I binds Collection to GridView using ObjectDataSource Control.
Under the TemplateField for Dept of Person class looks like

<EditItemTemplate>
      <asp:DropDownList ID="cmbStatus" DataTextField="DeptName" SelectedValue='<%# Bind("Dept.DeptId") %>'
          DataValueField="DeptId" runat="server" CssClass="ddl150px ddlbg" 
          DataSourceID="deptCollection" />
      <asp:ObjectDataSource ID="deptCollection" runat="server" 
                   SelectMethod="GetDeptList" TypeName="LIMS.BusinessObject.Department" >
     </asp:ObjectDataSource>
 </EditItemTemplate>

Now my Grid gets binded using

            <asp:ObjectDataSource ID="PersonCollection" runat="server" 
                SelectMethod="GetPersonList" 
                TypeName="LIMS.BusinessObject.Person" 
                DataObjectTypeName="LIMS.DomainModel.Person" 
                DeleteMethod="Delete" InsertMethod="Create" UpdateMethod="Update" 
                ondeleting="PersonCollection_Deleting" 
                onupdating="PersonCollection_Updating">  
            </asp:ObjectDataSource>

Now when I tries to update this Person entity, it throws error because dropdown displays Value field and text field and Person entity needs a Dept Entity which is actually binded to dropdownlist

  • 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-25T16:54:35+00:00Added an answer on May 25, 2026 at 4:54 pm

    You shouldn’t use complex entities directly in the presentation layer aspx. Because if you domain model change, for example adding some field, you would update every aspx of your application. You should provide a “view model” like this:

    class PersonView
    {
      public int Age{get;set;}
      public string Name{get;set;}
    
      public int DeptId{get;set;}
      public string DeptName {get { ... }}
    }
    

    It shouldn’t be a DTO: you don’t need to transfer data to be serialized between hosts, but a model for the view.

    A thin layer can convert model entities to view models. It could be a DataObject well supported by ObjectDataSource.

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

Sidebar

Related Questions

If I have entities like: @Entity public class Person { public String name; @OneToMany
I have an entity like this: public class Person { public string Name {
I have an entity Person: public class Person { public virtual int Id {get;
I have the following property defined: @Entity @Table(name = person) public class Person extends
Given the model: public abstract class Person { public int Id {get;set;} } public
Assume the following schema class Person{ public int Id {get;set;} public virtual ICollection<Province> Provinces
Let's say we have an entity @Entity public class Person { @Id int id;
Let's say I have this entity (for Hibernate): @Entity public class Person { @Id
I have a Person and an Organisation Entity: Person looks like this: public class
i have the two classes Person and Attribut, in short: @Entity @Indexed @Table(name=persons) public

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.