如何分配gridview标题文本

时间:2015-03-19 12:47:28

标签: asp.net gridview c#-3.0

我正在为我的大学开发一个自动结果表,我还附上了结果表的屏幕截图。我几乎能够使用gridview开发95%的结果表,现在我唯一的问题是我不知道如何为每列分配第二个标题。正如您在图像中看到的那样,有5个主题(P11MCA51,..,P11MCA55),每个主题有6个字段(C,S,T,CR,GP,GR)。从下面的代码我已经开发直到主题代码,但我卡住,因为我不知道如何插入这6个字段。

<pre>
    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" Height="3px" 
            Width="550px" Visible="True">
            <HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="USN" HeaderText="Usn" SortExpression="USN"  ReadOnly = "true"/>
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"  ReadOnly = "true"/>
                <asp:TemplateField HeaderText="P11MCA41" ItemStyle-Width="200px">
                 <ItemTemplate>
                 <asp:TextBox ID="C" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="S" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="T" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="CR" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="GP" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="GR" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 </ItemTemplate>
                 </asp:TemplateField>

                 <asp:TemplateField HeaderText="P11MCA42" ItemStyle-Width="200px"> 
                 <ItemTemplate>
                 <asp:TextBox ID="C" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="S" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="T" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="CR" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="GP" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 <asp:TextBox ID="GR" runat="server" Width = "30px" ReadOnly = "true" Text='<%# Eval("T1") %>' />
                 </ItemTemplate>
                 </asp:TemplateField>



            </Columns>
            <PagerStyle BorderColor="#660033" />
            <RowStyle BackColor="#CCFFCC" BorderColor="#6600FF" BorderStyle="Double" />
        </asp:GridView>
    </pre>

图片链接:“https://plus.google.com/photos/105587850868503389652/albums/6127575275561544033/6127575300226827650?pid=6127575300226827650&oid=105587850868503389652&authkey=CNeHoLjSzMmAigE

1 个答案:

答案 0 :(得分:0)