locked
Merge two columns into one and display in datagridview

    Question

  • I am a newbie.  This should be a simple question... I would like to know how to merge two columns coming from a linq query and display a combination of the columns plus the merged columns as one column?

     

    For example.. I want to display the column of first name and last name as full name. The linq query i was using is as follows:

     

    Dim allClients = From clients In db.clients _

    Order By clients.client_no _

    Select clients

     

    Dim concatClients = From clients In allClients _

    Select clients.client_no, clients.type, clients.client_surname & clients.first_name

     

    Sunday, November 04, 2007 12:15 PM

Answers

  • I'm not certain on what the story is with VB... but it seems like you would need to give a name to the calculated column.  That is:

    Dim allClients as IQueryable (Of Client)


    allClients = From clients In db.clients _

    Order By clients.client_no _

    Select clients

     

    Dim concatClients = From clients In allClients _

    Select _

    clients.client_no, clients.type, _

    FullName = clients.client_surname & clients.first_name


    Tell me if this helps.  If not, what exactly is the problem?  Are you getting a compile-time error, or is it not returning the result you wanted?

    Joe
    Sunday, November 04, 2007 12:35 PM

All replies

  • I'm not certain on what the story is with VB... but it seems like you would need to give a name to the calculated column.  That is:

    Dim allClients as IQueryable (Of Client)


    allClients = From clients In db.clients _

    Order By clients.client_no _

    Select clients

     

    Dim concatClients = From clients In allClients _

    Select _

    clients.client_no, clients.type, _

    FullName = clients.client_surname & clients.first_name


    Tell me if this helps.  If not, what exactly is the problem?  Are you getting a compile-time error, or is it not returning the result you wanted?

    Joe
    Sunday, November 04, 2007 12:35 PM
  • Fantastic it worked and I now understand how to use it.  Joe thanks for the really quick reply..

     

    Sunday, November 04, 2007 12:43 PM
  • how i can make it for a new properti os ta table, for example fullname i don't want make a calculated column on my table in the database but i want it on may datacontent always

     

    Monday, January 21, 2008 7:34 PM