.net displaying data within a datagrid question(s)

Discussion in 'OT Technology' started by bonerwad, Dec 11, 2003.

  1. bonerwad

    bonerwad New Member

    Joined:
    Oct 25, 2003
    Messages:
    164
    Likes Received:
    0
    Location:
    I like cheese.
    Ok, I've got a SQL table with a model, cpu, bus speed, ram, cd drive, floppy, mouse, keyboard, lan, video, software, cost, service tag, recv date, wty date.

    most of the computers are exactly the same, except the service tag, recv date, wty date. right now i have a datagrid that just shows the quantity of each of the computers (just 'group'ing by everything except service tag, recv, wty)

    so if there's 5 computers, i'd like to show five computers underneith the row, shows the service tag, recv, wty.

    something like this poorly rendered text:

    Qty Model CPU Bus Ram CD1 FD MS KB LAN VIDEO Software COST
    5 Dimension 2400 533 0 48x cdrw 0 Y Y 100 Int XP Home $289
    Service Tag Recv Date Wty Thru
    1 of 5 5YKTT21 12/22/03 12/22/04
    2 of 5 9LD49XX 12/23/03 12/23/04
    3 of 5 12YHV21 12/24/03 12/24/04
    4 of 5 9YNTLK1 12/24/03 12/24/04
    5 of 5 H214JCZ 12/31/03 12/31/06

    i was thinking making a datagrid inside of a datagrid, but i think that's way to damn complex...

    if you guys/gals can think of anything, it would be extreamly helpful

    thanks!
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    meh, i wouldn't screw around with creating 2 datagrids, or one inside the other for that matter. Why not just build your own solution and create an html table of your own format. If you REALLY want to dig into the .NET framework you could probably inherit a datagrid and build your own...
     
  3. Scoob_13

    Scoob_13 Anything is possible, but the odds are astronomica

    Joined:
    Oct 5, 2001
    Messages:
    73,784
    Likes Received:
    38
    Location:
    Fort Worth. Hooray cowgirls.
    Um, no.

    What you need to do is use 1 DataSet that contains multiple Tables (DataSet.Tables in C#).

    For this line:
    Code:
    Qty Model CPU Bus Ram CD1 FD MS KB LAN VIDEO Software COST
    
    You can actually add columns to each table, and you can name them whatever you want. When you bind the DataSet to the DataGrid it will automatically use the names of the columns - you can overwrite this after binding, if case you don't want to use the name (for my tools that query databases, I bind the results table directly to the DataGid - thus I use whatever I named the columns in the db or selected the field as to name my columns).

    Now, I'm assuming that this is also in a stand-alone app, because I'm fairly certain you would do this different for a web page (I don't develop much ASP-wise). You can translate this into ASP and whatnot, but for now I'll assume it's standalone.

    Anyhow, you now have a DataSet with multiple tables - one for the results of the query for service, one for the results of the system query, and one for the main results set. There is actually a way to link to another record within a DataGrid that allows the user to click a + to get more information - these are made by binding the key fields within the tables, and are easily set up if you know where to look for the information.

    Order the book "Professional C# 2nd Edition" or whatever edition is the latest, by Simon Robinson et. al., it's from Wrox, and it's the absolute BEST C# book out there for figuring all of this stuff out. And of course, you can always ask all of us.
     
  4. ChosenGSR

    ChosenGSR Mama always said you'd be the chosen one

    Joined:
    Oct 24, 2001
    Messages:
    50,976
    Likes Received:
    212
    Location:
    HoCo, MD
    Impreza13 is on the right track. If you wish to group computer by their hardware this will actualy require a cross-reference between computers and their hardware. You create 2 tables and link them using a relation. The relation link them by a common field. After which you can create a datagrid by listing the parent (hardware) and all of its children underneath (all the boxes that have that hardware with their IDs). A great way to do this is using a hierarchy(although not necesary). Search for hierarchial datagrid.

    oh and hsmith, datagrid is best thing since sliced bread if you are a web developer.
     
  5. bonerwad

    bonerwad New Member

    Joined:
    Oct 25, 2003
    Messages:
    164
    Likes Received:
    0
    Location:
    I like cheese.
    so how do you do that? i have seen a webcontrol that somebody else made, although i'd like to stay away from that.

    i know the datagrid on windows can do this really easy as I've done it a few times, just haven't done multiple tables in dataset on a datagrid on asp.net
     
  6. ChosenGSR

    ChosenGSR Mama always said you'd be the chosen one

    Joined:
    Oct 24, 2001
    Messages:
    50,976
    Likes Received:
    212
    Location:
    HoCo, MD

    http://www.dotnetjunkies.com/Tutorial/841522C9-FFBD-4C57-BD48-F62B55057FF3.dcik

    best shiznit out there, used it a million times.
     

Share This Page