Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binding controls to a DataTable
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01604545
Message ID:
01604559
Views:
45
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform