Textbox Databind

  • Thread starter Thread starter mjpiedade
  • Start date Start date
M

mjpiedade

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
 
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.RowFilter = "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.DataBind();//notice that datasource properity of the datagid
should be set to my_dataview
Hope that would help
 
Back
Top