multiple data items in each column

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default multiple data items in each column

    How can I display more than one field in a column of a datagrid?

    i.e. doing this with old asp and looping thru a recordset it would be
    something like:

    <table>
    do while not eof
    <tr>
    <td>ABC</td>
    <td>DEF</td>
    </tr>
    <tr>
    <td>GHI</td>
    <td>JKL</td>
    </tr>
    read next
    loop
    </table>

    Thank you


    xzzy Guest

  2. Similar Questions and Discussions

    1. Putting multiple items into a single column in adatagrid
      Okay, So I can put information into a datagrid, I can select a row and make sure that it populates that row. I can even make it hit that specific...
    2. add multiple items to cart
      hi all, my detail pg consists of ingredients to a recipe. a repeat region behaviour is added to my table of ingredients. i need to add all the...
    3. Delete Multiple items with checkboxes
      Hello all, I'm sorry for posting this because you probably answered this question a million times, but i didn't got my script to run yet. I'm...
    4. AS2 help: manipulate properties of multiple items
      The mission: create multiple MCs (see the attachment) of a library item (a ball) that is linked with a class. At runtime, if user presses "q", ALL...
    5. Select multiple items from a dropdown
      I want an ASP page with a dropdown and a simple button. Every time the user chooses an item from the dropdown and clicks on the button i want that...
  3. #2

    Default Re: multiple data items in each column

    I've never done it but I'd suspect that you could use an item template
    column and then just put the following code in there:

    <ItemTemplate>
    <asp:Label id=Label1
    runat="server"
    Text='<%# DataBinder.Eval(Container.DataItem, "FieldName1") %>'>
    </asp:Label>
    <asp:Label id=Label1
    runat="server"
    Text='<%# DataBinder.Eval(Container.DataItem, "FieldName2") %>'>
    </asp:Label>
    </ItemTemplate>


    Zach

    xzzy wrote:
    > How can I display more than one field in a column of a datagrid?
    >
    > i.e. doing this with old asp and looping thru a recordset it would be
    > something like:
    >
    > <table>
    > do while not eof
    > <tr>
    > <td>ABC</td>
    > <td>DEF</td>
    > </tr>
    > <tr>
    > <td>GHI</td>
    > <td>JKL</td>
    > </tr>
    > read next
    > loop
    > </table>
    >
    > Thank you
    >
    >
    Zach Wells Guest

  4. #3

    Default Re: multiple data items in each column

    Zach Wells wrote:
    >> How can I display more than one field in a column of a datagrid?
    >
    > I've never done it but I'd suspect that you could use an item template
    > column and then just put the following code in there:
    >
    > <ItemTemplate>
    > <asp:Label id=Label1
    > runat="server"
    > Text='<%# DataBinder.Eval(Container.DataItem, "FieldName1") %>'>
    > </asp:Label>
    > <asp:Label id=Label1
    > runat="server"
    > Text='<%# DataBinder.Eval(Container.DataItem, "FieldName2") %>'>
    > </asp:Label>
    > </ItemTemplate>
    While this will definitely display two records in one table row, it will
    not generate the HTML the original poster was interested in. Namely, it
    won't necessarily have the second Label's value line up in each row, as
    it would with the desired HTML provided originally.

    To get the HTML rendered as specified in the original post, one would
    need to use a DataList with RepeatColumns set to 2, or a Repeater,
    generating the apporpriate HTML markup.

    To learn more about the three Data Web controls check out:

    Deciding When to Use the DataGrid, DataList, or Repeater
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-whenusedatawebcontrols.asp[/url]

    Or check out my book, ASP.NET Data Web Controls Kick Start
    [[url]http://www.amazon.com/exec/obidos/ASIN/0672325012/4guysfromrollaco][/url]

    Happy Programming!

    --

    Scott Mitchell
    [email]mitchell@4guysfromrolla.com[/email]
    [url]http://www.4GuysFromRolla.com[/url]
    [url]http://www.ASPFAQs.com[/url]
    [url]http://www.ASPMessageboard.com[/url]

    * When you think ASP, think 4GuysFromRolla.com!
    Scott Mitchell [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139