C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Manually bind controls to Binding Source


Posted Date: 16 Apr 2007    Resource Type: Code Snippets    Category: Databinding

Posted By: Balamurali Balaji       Member Level: Diamond
Rating:     Points: 10



The following code is used to bind the controls in a form to a bindingsource.



SqlDataAdapter myAdapter;
DataSet myDataSet;
BindingSource myBinding;



This code can be placed inside the form's load event to create a bindingsource object and bind the controls to the bindingsource. This example uses the Customers table in the northwind sample database.


string connstring = "Data Source=.;Integrated Security=True;Initial Catalog=northwind";
myAdapter = new SqlDataAdapter("select * from customers", connstring);
myAdapter.TableMappings.Add("Customers", "Customers");
myDataSet = new DataSet();
myAdapter.Fill(myDataSet, "Customers");
myBinding = new BindingSource(myDataSet, "Customers");
this.textBox1.DataBindings.Add(new Binding("Text", myBinding, "Customerid", true));
this.textBox2.DataBindings.Add(new Binding("Text", myBinding, "CompanyName", true));
MessageBox.Show("Binding source created and Controls are data-bound");







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Previous Resource: XML to Radio button
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween masks

Contact Us    Privacy Policy    Terms Of Use