Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to save the connection string in a class library pro
Message
From
16/10/2007 11:17:12
 
 
To
16/10/2007 10:59:24
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01261098
Message ID:
01261259
Views:
12
>Can you demonstrate how you would do so for a base textbox class, for example?

Sure Mike ... simplified version:

m_BoundTable and m_BoundColumn are fields that are exposed as public properties, so they can be set in the Property sheet if you wish.
public virtual void DataBind(System.Data.DataTable Data, string Path)
{
	for (int i = 0; i < this.DataBindings.Count; i++)
	{
		if (this.DataBindings[i].Equals(this.oBinding))
		{
			this.DataBindings.Remove(this.oBinding);
			break;
		}
	}

	this.Text = "";
	this.m_BoundTable = Data;
	this.m_BoundColumn = Path;
	this.oBinding = new Binding(this.m_BoundProperty, Data, Path);
	this.oBinding.Format += new ConvertEventHandler(this.FormatHandler);
	this.oBinding.Parse += new ConvertEventHandler(this.ParseHandler);
	this.DataBindings.Add(this.oBinding);
}
~~Bonnie


>
>Thanks!
>
>>Hi Sergio,
>>
>>To databind, simply add to the DataBinding collection of each control:
>>
>>
>>this.txtOne.DataBindings.Add("Text", dsData.Tables[0], "MyFirstColumn");
>>this.txtLast.DataBindings.Add("Text", dsData.Tables[0], "MyLastColumn");
>>
>>
>>In our "Framework", I've created a DataBind() method in each of my controls. I recommend doing something like that in all your base control classes.
>>
>>~~Bonnie
>>
>>
>>
>>
>>
>>>Hello Bonnie,
>>>
>>>I have followed your advice about n-tier and I have the following question.
>>>
>>>I have a winform that calls a business class that return a dataset(dsData).
>>>
>>>How do I bind my textboxes on my form to this dataset???.
>>
>>>
>>>Below is the code of my form
>>>
>>>
>>>using System;
>>>using System.Collections.Generic;
>>>using System.ComponentModel;
>>>using System.Data;
>>>using System.Drawing;
>>>using System.Text;
>>>using System.Windows.Forms;
>>>
>>>using UPCI.WinUI;
>>>using UPCI.Atlas.Business.MyBiz;
>>>
>>>namespace UPCI.Atlas.WinUI.MyUI
>>>{
>>>    public partial class Policy : UPCIForm
>>>    {
>>>        private string PolicyNumber;
>>>        private DataSet dsData;
>>>        private PolicyBiz oBiz;
>>>
>>>        // Need to save the polid so  later I can get related info
>>>        public string PolID;
>>>
>>>        public Policy(string pn)
>>>        {
>>>
>>>            this.PolicyNumber = pn;
>>>            InitializeComponent();
>>>
>>>            this.FillData();
>>>        }
>>>        public void FillData()
>>>        {
>>>            // I'm directly calling a Biz class. In reality, a Web Service
>>>            // should be here which calls the Biz class
>>>            oBiz = new PolicyBiz();
>>>            dsData = oBiz.GetPolicy(this.PolicyNumber);
>>>
>>>
>>>
>>>        }
>>>
>>>        private void Policy_Load(object sender, EventArgs e)
>>>        {
>>>
>>>        }
>>>
>>>        private void Policy_Layout(object sender, LayoutEventArgs e)
>>>        {
>>>            //this.tabControl1.Dock = DockStyle.Fill;
>>>        }
>>>
>>>
>>>    }
>>>}
>>>
>>>
>>>
>>>Thanks,
>>>Sergio
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform