DataGrid display

S

Stephen

Hi,

Can a datagrid display be split into 2 rows.
for e.g: suppose my resultset has 20 columns and I want to display 10 in the
first row and and rest in another so that the display is not kludgy.
is it possible?

Thanks,
Stephen
 
G

Guest

Each DatagridItem renders a separate table row, within that DataGridItem you
might create an ItemTemplate for each column that contains a table of two
rows (one for each column in your datatable) .
<ItemTemplate >
<table >
<!--- this row would display col1--->
<tr>
<td >
<asp:Label ID="lblCompanyName" Runat=server Text='<%#
DataBinder.Eval(Container.DataItem, "Col1")%>'></asp:Label>
</td>
</tr>
<!--- this row would display col8 (assuming there 14 columns in the table,
the first 7 would be in the first row -->
<tr >
<td>
<asp:Label ID="lblCompanyName" Runat=server Text='<%#
DataBinder.Eval(Container.DataItem, "Col8")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>


Though, you might want to consider a DataList instead, where each item is a
tablecell. This gives you more freedom to create a template that contains an
HTMLTable with two rows. Or a repeater.
 
S

Stephen

Thanks Phillip,

Phillip Williams said:
Each DatagridItem renders a separate table row, within that DataGridItem you
might create an ItemTemplate for each column that contains a table of two
rows (one for each column in your datatable) .
<ItemTemplate >
<table >
<!--- this row would display col1--->
<tr>
<td >
<asp:Label ID="lblCompanyName" Runat=server Text='<%#
DataBinder.Eval(Container.DataItem, "Col1")%>'></asp:Label>
</td>
</tr>
<!--- this row would display col8 (assuming there 14 columns in the table,
the first 7 would be in the first row -->
<tr >
<td>
<asp:Label ID="lblCompanyName" Runat=server Text='<%#
DataBinder.Eval(Container.DataItem, "Col8")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>


Though, you might want to consider a DataList instead, where each item is a
tablecell. This gives you more freedom to create a template that contains an
HTMLTable with two rows. Or a repeater.

--
[note: if this post answers your question, you can mark it as an answer
using the web-based newsreader functions]
-----
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


Stephen said:
Hi,

Can a datagrid display be split into 2 rows.
for e.g: suppose my resultset has 20 columns and I want to display 10 in the
first row and and rest in another so that the display is not kludgy.
is it possible?

Thanks,
Stephen
 

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

Similar Threads


Top