How to make a datagrid column a row

Discussion in 'ASP .Net' started by Ken B, Sep 25, 2007.

  1. Ken B

    Ken B Guest

    How can I make a datagrid column into a single row that spans all the
    other columns?
    In this case I have a comment field that I want to make as wide as the
    table but I cannot figure out how to tell asp.net datagrid that I want
    a new row.

    I am using visual studio 2005,

    Thanks to anybody who has tried this and has a solution

    KB
     
    Ken B, Sep 25, 2007
    #1
    1. Advertising

  2. You may look at using a repeater with 2 rows in the itemtemplate. Something
    like this:

    <asp:repeater>
    <headertemplate>
    <table>
    </headertemplate>
    <itemtemplate>
    <tr runat="server" id="trNormal">
    <td>Databind expression for column 1</td>
    <td>Databind expression for column 2</td>
    <td>Databind expression for column 3</td>
    </tr>
    <tr runat="server" id="trComment">
    <td columnspan=3>Databind expression for comment</td>
    </tr>
    </itemtemplate>
    </asp:repeater>
    <footertemplate>
    </table>
    </footertemplate>

    and handle ItemDataBound event to hide trNormal or trComment as needed.
    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Ken B" <> wrote in message
    news:...
    > How can I make a datagrid column into a single row that spans all the
    > other columns?
    > In this case I have a comment field that I want to make as wide as the
    > table but I cannot figure out how to tell asp.net datagrid that I want
    > a new row.
    >
    > I am using visual studio 2005,
    >
    > Thanks to anybody who has tried this and has a solution
    >
    > KB
    >
     
    Eliyahu Goldin, Sep 25, 2007
    #2
    1. Advertising

  3. Hello Ken,

    U need to handle RowDataBound event making changes to your rows there

    see sample there http://dotnetjunkies.com/WebLog/joshuagough/archive/2006/06/23/141038.aspx

    ---
    WBR,
    Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo


    KB> How can I make a datagrid column into a single row that spans all
    KB> the
    KB> other columns?
    KB> In this case I have a comment field that I want to make as wide as
    KB> the
    KB> table but I cannot figure out how to tell asp.net datagrid that I
    KB> want
    KB> a new row.
    KB> I am using visual studio 2005,
    KB>
    KB> Thanks to anybody who has tried this and has a solution
    KB>
    KB> KB
    KB>
     
    Michael Nemtsev, MVP, Sep 25, 2007
    #3
    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. Bazza Formez
    Replies:
    4
    Views:
    423
    Vanni Tomezzoli
    Dec 9, 2004
  2. Luis Esteban Valencia

    Make a DataGrid row editable after user selects the row

    Luis Esteban Valencia, Jan 12, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    365
    Luis Esteban Valencia
    Jan 12, 2005
  3. Ping-Hsun Hsieh
    Replies:
    1
    Views:
    454
    Jon Clements
    Nov 19, 2009
  4. johnsonlim026
    Replies:
    0
    Views:
    962
    johnsonlim026
    Feb 27, 2010
  5. D
    Replies:
    0
    Views:
    257
Loading...

Share This Page