[英]Change the color of a row or record on a gridview on asp.net c#?
[英]Ask to change layout of the GridView on ASP.NET by C#
很抱歉这个愚蠢的问题,但我确实需要问一下处理此任务的方法。 我在这里研究了许多已解决的问题,但可以将其应用于我的任务。 也许我还不够了解。 请给我建议。
我的项目是由C#编写的。 他们使用GridView来显示数据库中的数据。 但是现在,我的客户希望使用GridView并创建一个与旧表相同的显示表,但是方式有所不同。
我当前显示的表如下:
No. | Name | DOB | Status | ...
1 | Name A | 01/01/2014 | Onl | ...
2 | Name B | 01/01/2014 | Off | ...
3 | Name C | 01/01/2014 | Off | ...
4 | Name D | 01/01/2014 | Onl | ...
现在,我想以这种方式更改它:
No. | 1
Name | Name A
DOB | 01/01/2014
Status| Onl
---------------------------------
No. | 2
Name | Name B
DOB | 01/01/2014
Status| Onl
---------------------------------
No. | 3
Name | Name C
DOB | 01/01/2014
Status| Onl
---------------------------------
No. | 4
Name | Name D
DOB | 01/01/2014
Status| Onl
---------------------------------
重要说明:仅使用GRIDVIEW。
请别人帮我完成这项任务。 我不太擅长ASP.NET。 非常感谢。
如果当前代码如下所示。
<Columns>
<asp:BoundField DataField="No." HeaderText="No." />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="DOB" HeaderText="DOB" />
<asp:BoundField DataField="Status" HeaderText="Status" />
</Columns>
您可以如下更改。
<Columns>
<asp:TemplateField HeaderText="Key">
<ItemTemplate>
<asp:Label ID="Label1" runat="server">No.</asp:Label><br />
<asp:Label ID="Label2" runat="server">Name</asp:Label><br />
<asp:Label ID="Label3" runat="server">DOB</asp:Label><br />
<asp:Label ID="Label4" runat="server">Status</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Value">
<ItemTemplate>
<asp:Label ID="Label5" runat="server"><%# Eval("No.") %></asp:Label><br />
<asp:Label ID="Label6" runat="server"><%# Eval("Name") %></asp:Label><br />
<asp:Label ID="Label7" runat="server"><%# Eval("DOB") %></asp:Label><br />
<asp:Label ID="Label8" runat="server"><%# Eval("Status") %></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.