Datagrid summary column

Discussion in 'ASP .Net Datagrid Control' started by anon, Apr 20, 2004.

  1. anon

    anon Guest

    Hi All,
    Perhaps a simple question, but i m unable to get an idea of how to
    accomplish this...
    i have a customer table and another table which has their details
    (maynot be available for all customers)...i would liek to display this
    information in a datagrid....with one row for each customer and a
    summary column which has the concatenated details field from second
    table....i have built the datagrid without the summary column
    succesfully...any ideas on how to accomplish this?
    thanks for ur time....
    Ben

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    anon, Apr 20, 2004
    #1
    1. Advertising

  2. > i have a customer table and another table which has their details
    > (maynot be available for all customers)...i would liek to display this
    > information in a datagrid....with one row for each customer and a
    > summary column which has the concatenated details field from second
    > table....i have built the datagrid without the summary column
    > succesfully...any ideas on how to accomplish this?
    > thanks for ur time....


    Get all the pertinent dat back in one SQL statement using a JOIN.
    Something like:

    SELECT C.Name, CD.Detail1, CD.Detail2
    FROM Customers C
    LEFT JOIN CustomerDetails CD ON
    C.CustomerID = CD.CustomerID

    Then use a TemplateColumn to display the pertinent fields in the second
    column, something like:

    <asp:DataGrid ...>
    <Columns>
    ...
    <asp:TemplateColumn>
    <ItemTemplate>
    Details 1:
    <%# DataBinder.Eval(Container.DataItem, "Details1") %>
    <br />Details 2:
    <%# DataBinder.Eval(Container.DataItem, "Details2") %>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>

    Happy Programming!

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Apr 21, 2004
    #2
    1. Advertising

  3. anon

    anon Guest

    hi scott,
    that helps, however i donot know before hand how many detail rows are
    available for each customer.....some might have 3 rows, some two, some
    none...so there is only one field.... detail1...there might be 3 or 2 or
    none rows of detail1 for each customerID....like this....
    Customer ID Name
    1 JOhn
    2 Matt
    CustomerDetail1
    1 value1
    1 value2
    1 value3
    2 value4
    2 value5

    the datgrid shud display like this:
    1 John value1
    value2
    value3
    2 Matt value4
    value5

    i didnot know clearly if your idea will fit this scenario....please
    advice....i greatly appreciate your help...
    thanks,
    ben

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    anon, Apr 21, 2004
    #3
  4. anon

    anon Guest

    anon, Apr 21, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hammond
    Replies:
    1
    Views:
    3,652
    bruce barker
    Nov 26, 2003
  2. Hai Nguyen
    Replies:
    0
    Views:
    409
    Hai Nguyen
    Jan 16, 2004
  3. Dexter
    Replies:
    1
    Views:
    426
    Eliyahu Goldin
    Jan 18, 2005
  4. John E.
    Replies:
    3
    Views:
    4,486
    masoud bayan
    Mar 25, 2005
  5. =?Utf-8?B?V2FyYW4=?=

    HyperLink Column and Button Column in a DataGrid

    =?Utf-8?B?V2FyYW4=?=, Aug 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    612
    =?Utf-8?B?V2FyYW4=?=
    Aug 9, 2005
Loading...

Share This Page