Simple DataBinding to TextBox : Data Bind TextBox « Database ADO.net « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Database ADO.net » Data Bind TextBoxScreenshots 
Simple DataBinding to TextBox



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;

class Form1 : Form {
    public Form1() {
        InitializeComponent();
        DataSet ds = CreateDataSet();
        textBox.DataBindings.Add("Text", ds.Tables["Products"]"ProductName");
    }

    private DataSet CreateDataSet() {
        string customers = "SELECT * FROM Products";
        DataSet ds = new DataSet();

        using (SqlConnection con = new SqlConnection(ConfigurationSettings.ConnectionStrings["northwind"].ConnectionString)) {
            SqlDataAdapter da = new SqlDataAdapter(customers, con);

            da.Fill(ds, "Products");
        }

        return ds;
    }

    private void InitializeComponent() {
        this.textBox = new System.Windows.Forms.TextBox();
        this.SuspendLayout();
        // 
        // textBox
        // 
        this.textBox.Location = new System.Drawing.Point(1313);
        this.textBox.Name = "textBox";
        this.textBox.Size = new System.Drawing.Size(47720);
        this.textBox.TabIndex = 0;
        // 
        // Form1
        this.Controls.Add(this.textBox);
        this.ResumeLayout(false);
        this.PerformLayout();

    }



    private System.Windows.Forms.TextBox textBox;
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.EnableRTLMirroring();
        Application.Run(new Form1());
    }
}


           
       
Related examples in the same category
1.Bind DataSet to TextBox
2.Bind String array to a TextBox
3.Bind Database table column to TextBox
4.DataView Binding to TextBox
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.