Question on DataTable.Select

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

    #1

    Question on DataTable.Select

    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.Custo mers 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.DataSo urce = DataSet1.Tables (0).Select("Cus tomerID = '" +
    sCustID + "'")

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

    Regards,
    Wan

  • Cor Ligthert [MVP]

    #2
    Re: Question on DataTable.Selec t

    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" <wandii@yahoo.c omschreef in bericht
    news:1167951187 .675371.275310@ 38g2000cwa.goog legroups.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.Custo mers 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.DataSo urce = DataSet1.Tables (0).Select("Cus tomerID = '" +
    sCustID + "'")
    >
    the Order of the columns in datagrid changes to - ContactName
    |CompanyName | CustomerID. Any ideas?
    >
    Regards,
    Wan
    >

    Comment

    Working...