- PR -

DataGridで1レコードを複数行で表示したい

投稿者投稿内容
キョウ
常連さん
会議室デビュー日: 2003/04/30
投稿数: 49
投稿日時: 2003-05-15 09:59
meiさんの方法はスマートですね。
私も実践させていただきたいと思います。

私は、TemplateColumnを使って対応しました。
TemplateColumnの中でHTMLのタグは自由に(100%かどうかは分かりませんが)
記述することができるので、そこでテーブルを作り、データをバインドしました。

説明が下手なのでお役に立てるか分かりませんがソースを掲げておきます。


<asp:datagrid id="grdResult" style="Z-INDEX: 101; LEFT: 80px; POSITION: absolute; TOP: 2px" runat="server" ShowHeader="False" CellPadding="0" BorderWidth="2px" BorderColor="Black" AutoGenerateColumns="False" Width="750px" GridLines="Horizontal" ShowFooter="True">
<ItemStyle Font-Size="X-Small" BackColor="White"></ItemStyle>
<HeaderStyle Wrap="False" BackColor="Blue"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<HeaderStyle Width="50px"></HeaderStyle>
<ItemStyle Font-Size="X-Small" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<FONT face="MS UI Gothic">&nbsp;</FONT>
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton id="CheckBox1" runat="server" width="50"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle Width="700px"></HeaderStyle>
<ItemStyle Font-Size="X-Small" Wrap="False"></ItemStyle>
<HeaderTemplate>
<FONT face="MS UI Gothic">
<TABLE id="Table6" borderColor="blue" cellSpacing="0" borderColorDark="black" cellPadding="0" width="700" border="1">
<TBODY>
<TR>
<TD width="700" colSpan="3"><STRONG><FONT color="white" size="2">aaaa: </FONT></STRONG>
</TD>
</TR>
<TR>
<TD width="700" colSpan="3"><STRONG><FONT color="white" size="2">bbbb: </FONT></STRONG>
</TD>
</TR>
<TR>
<TD width="700" colSpan="3"><STRONG><FONT color="white"><FONT size="2"><FONT face="MS UI Gothic">cccc:</FONT>
</FONT></FONT></STRONG>
</TD>
</TR>
<TR>
<TD width="400"><STRONG><FONT color="white"><FONT size="2"><FONT face="MS UI Gothic">dddd:</FONT> </FONT>
</FONT></STRONG>
</FONT></TD>
<TD width="149"><STRONG><FONT color="white"><FONT size="2"><FONT face="MS UI Gothic">eeee</FONT>
</FONT></FONT></STRONG>
</TD>
<TD width="149"><FONT size="2"><FONT face="MS UI Gothic" color="white"><STRONG>ffff</STRONG></FONT>
</FONT>
</TD>
</TR></TBODY></TABLE></FONT>
</HeaderTemplate>
<ItemTemplate>
<TABLE id="Table8" style="HEIGHT: 50px" borderColor="white" cellSpacing="0" borderColorDark="white" cellPadding="0" width="700" borderColorLight="black" border="1">
<TR>
<TD style="FONT-SIZE: x-small" width="700" colSpan="3" rowSpan="1"><%# DataBinder.Eval(Container.DataItem, "aaaa") %><FONT face="MS UI Gothic"></FONT></TD>
</TR>
<TR>
<TD style="FONT-SIZE: x-small" width="700" colSpan="3"><%# DataBinder.Eval(Container.DataItem, "bbbb") %><FONT face="MS UI Gothic"></FONT></TD>
</TR>
<TR>
<TD style="FONT-SIZE: x-small" width="700" colSpan="3" rowSpan="1"><%# DataBinder.Eval(Container.DataItem, "cccc") %><FONT face="MS UI Gothic"></FONT></TD>
</TR>
<TR>
<TD style="FONT-SIZE: x-small" width="400"><%# DataBinder.Eval(Container.DataItem, "dddd") %><FONT face="MS UI Gothic"></FONT></TD>
<TD style="FONT-SIZE: x-small" width="150"><%# DataBinder.Eval(Container.DataItem, "eeee").ToString() %><FONT face="MS UI Gothic"></FONT></TD>
<TD style="FONT-SIZE: x-small" width="150" colSpan="1" rowSpan="1"><%# DataBinder.Eval(Container.DataItem, "ffff") %><FONT face="MS UI Gothic"></FONT></TD>
</TR>
</TABLE>
</ItemTemplate>
<FooterTemplate>
<TABLE id="Table12" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR height="10">
<TD width="100">&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD width="295"></TD>
<TD>
<INPUT type="button" value="選択" width="150"></TD>
<TD>
<INPUT type="button" value="戻る" width="150"></TD>
</TR>
<TR height="10">
<TD width="300">&nbsp;</TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</FooterTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Font-Bold="True" HorizontalAlign="Right" ForeColor="White" BackColor="Blue"></PagerStyle>
</asp:datagrid>
やっち
会議室デビュー日: 2003/05/14
投稿数: 15
投稿日時: 2003-05-15 10:44
meiさん、リコさんありがとうございました。
調査、参考にさせていただきます。
未記入
ベテラン
会議室デビュー日: 2002/09/10
投稿数: 68
投稿日時: 2003-05-15 12:31
DataGirdではなく、
DataListを使ってみるのも、一つの手だと思います。

スキルアップ/キャリアアップ(JOB@IT)