|
-
Feb 27th, 2011, 01:30 PM
#1
Re: Finding row position of a Data Table
 Originally Posted by rushy
wow, thanks, works a treat, however having a slight issue that i had more than one customer in the combo box, but the filtering seems to leave me with just the Customer that has been selected. Thanks again
You can modify the filter according to your needs.
It is basically the WHERE part of your SQL statement.
e.g.
Code:
dttblCustomer.DefaultView.RowFilter = "CustomerID=1 OR CustomerID=2 OR CustomerID=3"
If it would be getting too complex, then it is always better to fill your datatable with only rows of your interest from your database with appropriate SQL query.
-
Feb 27th, 2011, 02:53 PM
#2
Thread Starter
Junior Member
Re: Finding row position of a Data Table
The problem i have is that it doesnt seem to filter down the customers, it will just show the customer in row(0) and therefore doesnt change at all when i change the number in the combo box. This is the reason i was looking for a little bit of help in getting the row position of the customername with customerid = combobox
your help so fars much appreciated though!
Last edited by rushy; Feb 27th, 2011 at 02:57 PM.
-
Dec 8th, 2013, 06:02 AM
#3
New Member
Re: Finding row position of a Data Table
 Originally Posted by rushy
The problem i have is that it doesnt seem to filter down the customers, it will just show the customer in row(0) and therefore doesnt change at all when i change the number in the combo box. This is the reason i was looking for a little bit of help in getting the row position of the customername with customerid = combobox
your help so fars much appreciated though! 
I want to tell you, that in the datasources tab, you make a connection with your database server and from there for example, you can drag the customer ID from the customer table to the CustomerID textbox and all the other fields that you want to link in your textboxes that you want to select the primary key from as your source, and then for example, if you have a related table, under the hierarchy of relations you select the table of the other table that you want to link for example Orders to the combobox, and it will take care of the DisplayMember (this is what you want to show inside the comboxBox) and the ValueMember (This is the CustomerID that you want to save in the other table that you want)
also for example, if you want to find a member or customer, then in the selected_change event of the comboBox, you write the code to call a Query for the CustomerTableAdapter.FillByCustomerID(CustomerDataTable, ComboBox.SelectedValue) This way it will take you directly to the record that you want to display through the bindingsource that is already automatically link with the previous drag that you performed.
Hope this works for you, there are many ways of doing this task, also using the datatable.select("CustomerID = '" & comboBox.SelectedValue & "'")
Good Luck
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|