473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Question on DataTable.Select

Wan
Hi,
I have a test project which contains two simple forms - 1st form
contains datagrid and couple of buttons. First button to populate the
grid with Northwind.Customers records and show 3 columns - CustomerID
|CompanyName| ContactName - works fine.

2nd button to bring up the second form contains a datagrid with
customer records with no sorting or order by. The problem is that when
I select one of the customer records and try to show the selected
record back to the 1st form in the datagrid as:

DataGrid.DataSource = DataSet1.Tables(0).Select("CustomerID = '" +
sCustID + "'")

the Order of the columns in datagrid changes to - ContactName
|CompanyName | CustomerID. Any ideas?

Regards,
Wan

Jan 4 '07 #1
1 1146
Wan,

If you are using the DataGrid than don't use the Select for that.

Use the DataView or and a new Dataview, with what you can represent the data
in another way

As extra it keeps the rownumber in tact if the user sorts that datagrid by
clicking on top.

Cor
"Wan" <wa****@yahoo.comschreef in bericht
news:11**********************@38g2000cwa.googlegro ups.com...
Hi,
I have a test project which contains two simple forms - 1st form
contains datagrid and couple of buttons. First button to populate the
grid with Northwind.Customers records and show 3 columns - CustomerID
|CompanyName| ContactName - works fine.

2nd button to bring up the second form contains a datagrid with
customer records with no sorting or order by. The problem is that when
I select one of the customer records and try to show the selected
record back to the 1st form in the datagrid as:

DataGrid.DataSource = DataSet1.Tables(0).Select("CustomerID = '" +
sCustID + "'")

the Order of the columns in datagrid changes to - ContactName
|CompanyName | CustomerID. Any ideas?

Regards,
Wan

Jan 5 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
1
by: MrMike | last post by:
I have the following code which allows me to display records from a table named "lkup_Specie" in a datagrid. If I create a second datatable and a second hashtable for a table named "lkup_Grade",...
3
by: Bruno Rodrigues | last post by:
Hi all I'm using the following code standart in class libraries. I will not split this function in more layers, but I want to know if there are some architetural improvement to do in my code....
3
by: Peter | last post by:
Hi, I have two datatables and I want to efficiently query the intersection of the two using the studentID. In my example code below, I want to print out Mary and Jane and their exam grades and I...
10
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting...
1
by: Diffident | last post by:
Hello All, I am trying to filter rows in a datatable based on filtercriteria and sortcriteria using the datatable.select() method. I am encountering a strange behavior in this process. Here is...
6
by: Woody Splawn | last post by:
I have a Winform where I fill a table with an associated dataset. This will put say 20 records into the table. I know this is elemental but... I want to see only one record from on my Winform...
5
by: ric_deez | last post by:
Hi there, I would like to create a simple search form to allow users to search for a job number based on a number of parameters. I think I understand how to use parameteres associated with Stored...
1
by: Kevin S. Goff | last post by:
Someone asked me how I would do the following....suppose you have two ADO.NET datatables, and you want to do the equivalent of SELECT Table1.*, Table2.* (in other words, do a linq query that...
6
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.