How to make a datagrid column a row

K

Ken B

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
 
E

Eliyahu Goldin

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
 
M

Michael Nemtsev, MVP

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top