Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binding controls to a DataTable
Message
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:
01604559
Vues:
46
>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 ?

If you've got a data source set up for the project you can do this in the designer:In the properties window for the control:

Expand (DataBindings) ;select (Advanced) and open the dialog.
Choose the property you want to bind (eg for a TextBox 'Text') then in the 'Binding' dropdown just select the Table/Field that you want.

Duh - just saw this was a web app so the above won't apply :-{
In ASP.NET you can do it in markup : http://msdn.microsoft.com/en-us/library/bda9bbfx(vs.71).aspx
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform