Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Control - Setting BindingSource
Message
De
03/12/2004 15:13:21
 
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
00966165
Message ID:
00966816
Vues:
8
Hello

From the posts thus far I assume you are using windows controls and not web controls. The concept I suggest should work for both. I have created the following object for my web apps which gives me access to the web pages methods and objects. It has given me the ability to bind the WebGrid objects using the web pages .BindControl({control}) method.

Changes/Modifications

1. You should change the namespace to something useful for yourself.
2. BusinessWebPage property should be based on your MM form or web page at it's highest level without being specific e.g. mmBusinessForm versus mySalesForm. Replace dcgBusinessWebPage with your object mmBusinessForm.

Of course, when you use UserControls you will not have the kind of access to the data elements because you are not registering the controls on a MM Bindable form or object. You can still assign the data properties manually or programmatically. Using this object allows you complete access to the properties and methods of the form or web page. And it is simple.

Examples of use (Web version):
//get a reference to the business object within the usercontrol
//assign it to a UserControl property for future use
//any properties on the retrieved object are the same as if they were on the webform itself
this._Waiting = (Waiting) this.BusinessWebPage.GetBizObj("Waiting");

//Bind the grid control using the MM version of binding
//The BindControl method is only available on the mmBusinessWebPage
this.BusinessWebPage.BindControl(this.grdWaiting);
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;

using DCG.Main.Web.UI.Containers;

namespace DCG.Main.Web.UI.Containers
{
	/// <summary>
	/// Summary description for dcgUserControl.
	/// </summary>
	public class dcgUserControl : UserControl
	{
		public dcgUserControl()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		#region Object Properties
		/// <summary>
		/// A link to the mmBusinessWebPage
		/// </summary>
		[Browsable(false)]
		public dcgBusinessWebPage BusinessWebPage
		{
			get
			{
				return this._BusinessWebPage;
			}

			set
			{
				this._BusinessWebPage = value;
			}
		}
		protected dcgBusinessWebPage _BusinessWebPage = null;
		#endregion

		#region Object Events
		protected override void OnInit(EventArgs e)
		{
			base.OnInit (e);

			// This must be outside the Page.IsPostBack testing
			// This should be before the OnLoad, so that the Page_Load can see it properly
			this.SetBusinessWebPage();
		}

		public void SetBusinessWebPage()
		{
			if (this.BusinessWebPage == null)
			{
				this.BusinessWebPage = (dcgBusinessWebPage) this.Page;
			}
		}
		#endregion
	}
}
>I have read all the posts that are similar to my question here, but the answers posted do not solve my particular issue, so I am posting my question which I will try to explain as best I can.
>
>I have:
>- 1 Form (we'll call FormA)
>- 2 User Controls (We'll call UC1 and UC2)
>
>User Control UC2 is a simple user control that has 2 controls on it, the mmUltraCombo and a standard text box. This user control will be placed on a number of other user controls such as UC1 (see next sentence).
>
>User Control UC1 has a couple of standard text boxes on it, PLUS the user control UC2.
>
>Form 1 has a datagrid, a couple of buttons, as well as User Control UC1.
>
>I have the set the binding source of the datagrid. I have set the binding source of the text boxes on user control UC1.
>
>Via the MM Framework when i click on a row in the datagrid (during runtime), the corresponding detail information shows up in the user control UC1, EXCEPT for the controls on the user control UC2.
>
>Obviously when i placed the user control UC2 on the usercontrol UC1 I am not able to set the binding source of that control like i can with the other controls on UC1.
>
>But I want the same functionality to happen. When i click on a record in teh datagrid on FormA, I want all the controls on UC1 (which include UC2) to dispay the detail information, and that includes the user control UC2 (the combo box on UC2 displays drop down information pertaining to the record selected in the datagrid).
>
>I sincerely hope this made sense. I can send a screen shot if that would help with clarification.
>
>Any information will be greatly appreciated.
>
>Scott
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform