TextBox.Databindings.Add() question.


  • I have a dataset dsReceivedGoods. It has a table called dtPurchaseInvoice. I choose them as datasource for a datagrid so VS automatically creates two objects for it:

    1. dtPurchaseInvoiceBindingSource
    2. dtPurchaseInvoiceTableAdapter

    There is a column dcInvoiceNumber which is a primary key for dtPurchaseInvoice.

    I have a textbox on the form that I need to bind to this column. I Have tried the following but the value inside the datatable is always blank.

    txtInvoiceNumber.DataBindings.Add("Text", dtPurchaseInvoiceBindingSource, "dcInvoiceNumber");

    for dtPurchaseInvoiceBindingSource DataMember is : dtPurchaseInvoice and DataSource is dsRecieveGoods

    I dont know what I am doing wrong here...


    "I choose to win, I choose to fight"
    Monday, April 27, 2009 6:46 PM


  • Hi _Kalesh_,

    Base on my understanding, you want to bind dcInvoiceNumber in dtPurchaseInvoice with txtInvoiceNumber. You can do it in the VS designer.

    1. Click the "+" sign in front of "(DataBindings)" property.
    2. Set the Text property with the data field in the listed DataSource/BindingSource.

    If you have any question, please feel free to tell me.

    Kira Qian

    Please mark the replies as answers if they help and unmark if they don't.
    • Marked as answer by Kira Qian Monday, May 04, 2009 4:59 AM
    Wednesday, April 29, 2009 8:28 AM