473,703 Members | 3,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET 2.0 DataBinding with object oriented business classes

Hi ASP.NET 2.0 Professionals,

I've got a question concerning the new ASP.NET 2.0 DataBinding with object
oriented business classes:

Example:

There are two business classes in my domain model:

public class Language
{
public int ID;
public string Name;
}

public class User
{
public int ID;
public string Firstname;
public string Lastname;
public Language UserLanguage;
}

Now I want to bind objects of the two classes to the data controls of a
FormView control.

I am using two ObjectDataSourc e Controls "odsUser" to retrieve a User object
(linked to the FormView) and "odsLanguag es"
to fill a DropDownList with all possible Languages.

<asp:ObjectData Source ID="odsUser" runat="server" SelectMethod="G et"
TypeName="Domai nModel.Users.Us erStorage">
<SelectParamete rs>
<asp:QueryStrin gParameter DefaultValue="1 " Name="id" QueryStringFiel d="id"
Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>

<asp:ObjectData Source ID="odsLanguage s" runat="server" SelectMethod="G etAll"
TypeName="Domai nModel.Common.L anguageStorage" >
</asp:ObjectDataS ource>
The question is:

How do I bind the current Language of a User object to the DropDownList?

I tried this but the compiler doesn't like it:

<asp:DropDownLi st ID="ddlDropDown List" DataSourceID="o dsLanguages"
runat="server" DataTextField=" Name" DataValueField= "ID" SelectedValue=' <%#
Bind("Language. ID") %>' ></asp:DropDownLis t>

The Expression Bind("Language. ID") is not allowed here.
I think this is a typical data binding problem of any enterprise application
with an object oriented domain model.
Thanks in advance

- Ulrich Schumacher
Nov 19 '05 #1
2 3763
On Thu, 30 Jun 2005 10:08:06 -0700, ulrich schumacher wrote:
Hi ASP.NET 2.0 Professionals,

I've got a question concerning the new ASP.NET 2.0 DataBinding with object
oriented business classes:

Example:

There are two business classes in my domain model:

public class Language
{
public int ID;
public string Name;
}

public class User
{
public int ID;
public string Firstname;
public string Lastname;
public Language UserLanguage;
}

Now I want to bind objects of the two classes to the data controls of a
FormView control.

I am using two ObjectDataSourc e Controls "odsUser" to retrieve a User object
(linked to the FormView) and "odsLanguag es"
to fill a DropDownList with all possible Languages.

<asp:ObjectData Source ID="odsUser" runat="server" SelectMethod="G et"
TypeName="Domai nModel.Users.Us erStorage">
<SelectParamete rs>
<asp:QueryStrin gParameter DefaultValue="1 " Name="id" QueryStringFiel d="id"
Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>

<asp:ObjectData Source ID="odsLanguage s" runat="server" SelectMethod="G etAll"
TypeName="Domai nModel.Common.L anguageStorage" >
</asp:ObjectDataS ource>
The question is:

How do I bind the current Language of a User object to the DropDownList?

I tried this but the compiler doesn't like it:

<asp:DropDownLi st ID="ddlDropDown List" DataSourceID="o dsLanguages"
runat="server" DataTextField=" Name" DataValueField= "ID" SelectedValue=' <%#
Bind("Language. ID") %>' ></asp:DropDownLis t>

The Expression Bind("Language. ID") is not allowed here.
I think this is a typical data binding problem of any enterprise application
with an object oriented domain model.
Thanks in advance

- Ulrich Schumacher

Your classes must implement interfaces as follows:
Simple objects must implement the IEditableObject interface,
Collection objects must implement IBindingList intervace.

Nov 19 '05 #2
> Your classes must implement interfaces as follows:
Simple objects must implement the IEditableObject interface,
Collection objects must implement IBindingList intervace.


I'm not sure that this is necessary, there is a work-around

http://forums.asp.net/974170/ShowPost.aspx

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
3029
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
11
9255
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
15
3679
by: Tim Jarvis | last post by:
Hi, I have an object that I am binding to a text box, this object exposes a boolean field, and I have implemented a format event handler and a parse event handler for the binding object, where I convert the bool value to some meaningful text. i.e. Binding b = new
3
1858
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were automatically generated, and the objectdatasource let you design against a business object through the gui. Now I am working on my first real web application on 2.0, and I find this automatic functionality doesn't do much beyond allowing me to generate...
3
4223
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page that needs the class module I get an error on web site: Object reference not set to an instance of an object Here is where the error is:
5
3478
by: Trail Monster | last post by:
Ok, I've been searching the net now for several days and can't find how to do this anywhere. Version: VS 2005 Professional Release, 2.0 Framework Background: I have a complex business object Employee that contains public properties and several nested objects such as a Spouse object and a List of Coverage objects.
1
18851
by: Dave A | last post by:
Hi, I am struggling with two way databinding in WinForms and the DataGridView. I am binding to business object classes (rather than datatables). If I have a collection of these business objects that is the datasource of a DataBinding that is bound to a DataGridView (WinForms) then I was expecting that any change to the data would be reflected in the DataGridView (in other words I was expecting the 2 way databinding to actually...
8
2088
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the generic type Field<T> (see sample code). public class Employee { public Field<stringForename
7
2592
by: Vlado Jasovic | last post by:
Hello, I'm using typed dataset for databinding to windows controls and I'm having some problems. I'm trying to move all business logic to datatable column_changing events and the problem that I'm having is when I change some other column, control value doesn't update immediately until I call endcurrentedit on bindingmanager which doesnt happen until user click update button.
0
8749
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8662
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7853
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2057
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.