Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data Binding on webform
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Data Binding on webform
Miscellaneous
Thread ID:
01163566
Message ID:
01163566
Views:
46
I Posted this message Last Friday But I did not get any reply. I suppose its not possible ?

-----Old Message
I have a SecurityUserClass as show below in Figure 1. In this object I have a Contact Business Object and when I call the Getrow method It automatically calls the Contact Getrow. So when I use my SecurityUser Object I can use it like this.
oSecurityUser = new SecurityUser()
oSecurityUser.GetRow(<GUID>)
TextBox1.Text = oSecurityUser.oContact.Entity.FirstName
How can I bind the TextBox to FirstName using the BindingSource and BindingMember Object. Is it Possible ? Is my class design right ? can anyone help me.

I tried setting the properties in various combinations but not luck
1.
BindingSource=SecurityUser
BindingSourceTypeMember=FirstName
2.
BindingSource=SecurityUser.oContact
BindingSourceTypeMember=FirstName
3.
BindingSource=SecurityUser.oContact.Entity
BindingSourceTypeMember=FirstName

Figure 1
using System;
using System.Data;

using OakLeaf.MM.Main.Business;
using OakLeaf.MM.Main.Data;

namespace Cyberlogic.PM
{
	/// <summary>
	/// Summary description for SecurityUser.
	/// </summary>
	public class SecurityUser : ABusinessObject
	{
		
		#region Association Properties

        public virtual Contact oContact
        {
            get
            {
                if (this._contactentity == null)
                {
                    this._contactentity = new Contact();
                }
                return this._contactentity;
            }
            set { this._contactentity = value; }
        }
        private Contact _contactentity;
		/// <summary>
		/// Business Entity object
		/// </summary>
		public virtual SecurityUserEntity Entity
		{
			get
			{
				if (this._entity == null)
				{
					this._entity = new SecurityUserEntity();
				}
				this._entity.SetDataRow(this.DataRow);
				return this._entity;
			}
			set { this._entity = value; }
		}
		private SecurityUserEntity _entity;

		/// <summary>
		/// Business Rule object
		/// </summary>
		public virtual SecurityUserRules Rules
		{
			get { return (SecurityUserRules)this.BusinessRuleObj; }
			set { this.BusinessRuleObj = value; }
		}

		#endregion

		/// <summary>
		/// Constructor
		/// </summary>
		public SecurityUser()
		{
			TableName = "SecurityUser";
			PrimaryKey = "ID";
            SqlSelect = " select securityuser.*,FirstName,LastName from securityuser " +
                             "inner join contact on securityuser.Contactid = Contact.ID";
            SqlSort = " contact.LastName,contact.FirstName";
          

		}

		/// <summary>
		/// Factory method that creates a business rule object
		/// </summary>
		/// <returns>Reference to the business rule object</returns>
		protected override mmBusinessRule CreateBusinessRuleObject()
		{
			return new SecurityUserRules(this);
		}
        protected override bool HookPreAddNewRow(DataTable dt)
        {
            
            this.oContact.NewRow();
            return base.HookPreAddNewRow(dt);
        }
        protected override void HookPostAddNewRow(DataRow dataRow)
        {
            base.HookPostAddNewRow(dataRow);
        }
        public override void GetRow(Guid PrimaryKey)
        {
            base.GetRow(PrimaryKey);
            if (this.Entity.ContactID != null)
                oContact.GetRow(this.Entity.ContactID);
        }
        protected override void HookPostDelete(DataTable dt)
        {
            base.HookPostDelete(dt);
            oContact.Delete();
        }
        protected override void HookPostSave(DataTable dt)
        {
            base.HookPostSave(dt);
            oContact.SaveRow();
        }
}
Fred Besterwitch, MCP

The harder you work. The luckier you get.
Next
Reply
Map
View

Click here to load this message in the networking platform