Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binding controls to a DataTable
Message
De
24/07/2014 08:43:02
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01604545
Message ID:
01604564
Vues:
35
>Hi All, I've been binding WinForms controls to DataTables using the syntax shown below for years and wonder if there's a better way of doing it using a BindingSource - this is what I currently do
>
>
> this.txtLastAmendedUser.DataBindings.Add("Text", dt, "amend_user");
>
>
>where dt is a DataTable and "amend_user" is a field. I typically have a dozen or so controls on a form so it's quite a code intensive method. Is there a better / easier way of binding ?

I had a huge table like this, so I designed a naming convention for the text boxes that related to the columns in the dt and wrote a loop that did the bindings.
It only worked for textboxes. I had to do other controls on my own.
I've used that quite often since then for large tables, but for small tables I use the method you showed.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform