Data Grid - 2 rows per record?

C

Chu

Ok, my title may sound odd - let me explain what it means -

It's easy to setup a grid to display 1 row of information per database
record. Let's say this for example I have a grid display some customer
information such as First Name, Last name and Customer ID on one row.
But, what if there's a large comment for that customer, I could display
it in a 4th column, but if it's large enough it's going to cause some
undesired scrolling. Would there be any way to put that comment on a
2nd row (thus, 2 rows per record - first row contains First name, last
name, customer id, 2nd row contains the comment and spans over 3
columns)?

It would in theory be possible to do this using a itemTemplate and
outputting a <table> and a few <tr>'s to handle the data, however I
can't figure out how using an itemTemplate would still allow the
programmer to use the built-in functionality to sort by column --
because as far as the grid is concerned, there would be only one column
in the grid.

Any tips would be appreciated.

Thanks
RScott
 
M

Mischa Kroon

It would in theory be possible to do this using a itemTemplate and
outputting a <table> and a few <tr>'s to handle the data, however I
can't figure out how using an itemTemplate would still allow the
programmer to use the built-in functionality to sort by column --
because as far as the grid is concerned, there would be only one column
in the grid.

Any tips would be appreciated.

2 options:

1 process serverside add in the extra html to place the data in the row
below.
2 process through template with a function to spit out the html.
 
G

Guest

Chu,
The best solution to this issue is to put a hyperlink column in for the
column(s) that hold a large amount of text, and have that bring up a details
grid or even a popup window containing the details of a single row, laid out
perhaps with a DataList.
Peter
 
J

Jacek Stawicki

Uzytkownik "Chu said:
Ok, my title may sound odd - let me explain what it means -

It's easy to setup a grid to display 1 row of information per database
record. Let's say this for example I have a grid display some customer
information such as First Name, Last name and Customer ID on one row.
But, what if there's a large comment for that customer, I could display
it in a 4th column, but if it's large enough it's going to cause some
undesired scrolling. Would there be any way to put that comment on a
2nd row (thus, 2 rows per record - first row contains First name, last
name, customer id, 2nd row contains the comment and spans over 3
columns)?

It would in theory be possible to do this using a itemTemplate and
outputting a <table> and a few <tr>'s to handle the data, however I
can't figure out how using an itemTemplate would still allow the
programmer to use the built-in functionality to sort by column --
because as far as the grid is concerned, there would be only one column
in the grid.

I recommend you using Repeater Web Control:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate><table></HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label runat="server" ID="Label1" Text='<%#
Eval("AccountNumber") %>' />
</td>
</tr>
<tr>
<td><asp:Label runat="server" ID="Label2" Text='<%# Eval("Name")
%>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>

And some custom methods for sorting etc.
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top