473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Switching between datasources using bound controls

All,

I am using Windows Forms and have multiple XML datasets feeding various
controls. Here is the situation.

I have a master dataset that saves a document to the drive. Out of 50
fields in the XML document, there are 5 that have defaults loaded from
a different XML dataset when the new form is created.

In pseudocode

If New
Fee Dataset = openxml Fees.xml
txtFee1.text = Fee Dataset (Fee1)
Else
Document Dataset = openxml Document.xml
txtFee1.text = Document dataset (Fee1)
End If

The data is bound properly from the master dataset when I open an
document but won't load default data from the fee.xml file when a new
document is created.

I am assuming if I am creating a new document, I need to drop the
databinding for those fields from the document, and assign it to the
fee xml file, then switch it back. This is apparently wrong or I am
doing it wrong.

Any and all help is greatly appreciated

Thanks,
jaxmeier

Nov 21 '05 #1
1 960
This is the way I do it....Some of its specific to my needs but you should
get the idea....
Private Sub bindTextBoxes()
clearbindings()
Me.mCustomerCM = BindingContext( mCustomerCollec tion)
Me.txtCustNo.Da taBindings.Add( New Binding("text", mCustomerCollec tion,
"Custno"))
Me.txtCustAbbre viation.DataBin dings.Add(New Binding("text",
mCustomerCollec tion, "CustAbbr") )
Me.txtCustShort Name.DataBindin gs.Add(New Binding("text",
mCustomerCollec tion, "CustShortName" ))
Me.txtCustName. DataBindings.Ad d(New Binding("text",
mCustomerCollec tion, "CustName") )
Me.txtCustAddre ss.DataBindings .Add(New Binding("text",
mCustomerCollec tion, "CustAddres s"))
Me.txtCustCity. DataBindings.Ad d(New Binding("text",
mCustomerCollec tion, "CustCity") )
Me.txtCustState .DataBindings.A dd(New Binding("text",
mCustomerCollec tion, "CustState" ))
Me.txtCustZip.D ataBindings.Add (New Binding("text",
mCustomerCollec tion, "CustZip"))
Me.txtCustMfgNo .DataBindings.A dd(New Binding("text",
mCustomerCollec tion, "CustMfgNo" ))
Me.txtCustDistP ack.DataBinding s.Add(New Binding("text",
mCustomerCollec tion, "CustDistPack") )
Me.txtCustNo.Re adOnly = True

End Sub
Private Sub clearbindings()
Try
Me.txtCustNo.Re adOnly = False

Dim c As New Control

For Each c In Me.Controls
If c.GetType Is GetType(System. Windows.Forms.T extBox) Then
Console.WriteLi ne(c.Name)
c.DataBindings. Clear()
c.Text = Nothing
End If

Next
Catch ex As InvalidCastExce ption
'Catches a spurious error
Debug.WriteLine (ex.Message)

Catch ex As Exception

End Try
End Sub
Nov 21 '05 #2

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

Similar topics

0
1223
by: Jerry Boone | last post by:
Situation: In the process of building a wondrous desktop form to display "grand functionality"... Access has presented me with the challenge of combining multiple forms onto one single unbound form utilizing Tab controls as a way to switch out other unbound multifunctional data display forms. This is inside an ADP, but of course that doesn't matter in this case - it does the same thing in an MDB. Problem: While it is easy to drop a...
19
4109
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
0
2804
by: swethasivaram | last post by:
Hi all I am displaying some information from my database using DetailsView which is bound to SqlDataSource1. <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource1" ForeColor="#333333" > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
2
4361
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control displaying the contents of the data source, whilst another control updates the datasource via a command buttons implementation of 'Click', an event raised in the 'Handle Postback Events' stage of the control execution life cycle (via the...
8
1833
by: Joey Chömpff | last post by:
L.S., Hello is there a way to implement 2-way databinding without using the datasources from dotnet 2.0. Why would you ask? Now that's simple. I've created an object model with BusinessObjects and I don't want to write an separate provider layer for the datasources. This is because I loose all the benefits of my objectmodel. Are there other developers who think this way?
3
1113
by: rodchar | last post by:
hey all, i have a multiview control that has 2 views in it. View1 has a gridview bound to a SqlDataSource and View2 has a FormView bound to a SqlDataSource also. If, in the code, i don't set any views to be active does any binding still occur in the background but it's just not visible? thanks, rodchar
3
7245
by: jobs | last post by:
I've got a gridview that does not have a datasourceid assigned in the markup. I'd like to switch between two datasources in the codebehind. when I do switch, I first reset the the gridviewx.datasource = nothing and gridviewx.datasourceid = nothing before setting it to gridviewx.datasource = newdatasoruceid and then rebinding. All appears to work well until I try to excute a delete command that
0
1996
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have few questions and hopefully you can provide me some answers. 1. Best place for DataBinding. Where is the best place for calling DataBind method? Is it possible to say don't bind controls for this postback and use current values instead? These...
9
1617
by: alexandis | last post by:
I have a big database, a lot of tables, so I will have a lot of pages where i create a new record. There will be a lot of 'reference' items - let's say 'Create user' -> 'Select user type' <Dropdownlist-Admin, Partner, Client type A, Client type B, Contract (is taken from UserTypes table) Such 'reference' lists (based on 'reference' tables) should be used on several pages, I will have a lot of reference tables. So - what is the best...
0
9655
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
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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
9964
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
8993
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
7517
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...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
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.