Textbox Databind

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mjpiedade

    Textbox Databind

    I just started with C#.
    How do I navigate on a dataset by changing the value of a textbox or other
    simple bound controls? Imagine that I have the customer name on a textbox
    and have a datagrid with the orders that will display the orders of the
    customer that the user enters on the textbox.
    With combobox or lisbox the binding is automatically defined, but with
    controls with simple bound I just can not figure it out a easy way to do it.
    Actually, what I want to do is a select on the dataset, depending on the
    information the user puts on textbox.text.

    Thank you in advance for any help.
    Best regards,
    Miguel Piedade


  • Mohamoss

    #2
    RE: Textbox Databind

    Hi Miguel
    One way to do this is as follows
    1-Bind that DataGrid that you have to a DataView Object.
    2-Then on the TextChanged event handler of your TextBox do as follows
    - get the text from the text Box on a sting object lets name it S
    Set the row filter property of the dataview object according to criteria
    you want to filter on "lets say that you are getting the name of the
    customer and you want to see only the rows that belong to that customer "
    So you would do as follows
    My_dataview.Row Filter = "customer name = '"+ S + "'"// where customer
    //name is the name of the data column in your table, hence in your
    //dataview and your dataGrid
    Then you bind the dataview "once you sit the filter property "to your
    datagrid
    DataGrid1.DataB ind();//notice that datasource properity of the datagid
    should be set to my_dataview
    Hope that would help

    Comment

    Working...