0

我的桌子布局有问题。正如您在屏幕截图中看到的那样,gridview 中有一个网格视图。您看到的示例有 3 个网格视图,主视图和两个表中的一个。我想将描述放在价格 2 列中并删除第 3 个网格视图。你们能帮我找到让第二个表与下一列重叠的解决方案吗?

谢谢

http://img43.imageshack.us/img43/9384/tabelf.jpg

</head>
<body>
    <form id="form1" runat="server">

    <div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        AutoGenerateDeleteButton="False" AutoGenerateEditButton="False" 
        onrowcancelingedit="GridView1_RowCancelingEdit" 
        onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing" 
        onrowupdating="GridView1_RowUpdating" OnRowCommand="GridView1_RowCommand" style='table-layout: inherit'>
        <Columns>
        <asp:TemplateField HeaderText="Site ID">
            <ItemTemplate>
                <asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
         <%--<asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex%>'></asp:Label>--%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Service Name">
            <ItemTemplate>
                <asp:Label ID="lbl" runat="server" Text='<%#Eval("firstName") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txt" runat="server" Text='<%#Eval("firstName") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Price 1">
            <ItemTemplate>
                <asp:Label ID="lblPriceOne" runat="server" Text='test'></asp:Label>                              
                <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                    AutoGenerateDeleteButton="False" AutoGenerateEditButton="False">
                     <Columns>
                        <asp:BoundField DataField="lastName" HeaderText="lastName" SortExpression="lastName">
                            <ItemStyle Width="20%"/>
                        </asp:BoundField>
                        <asp:BoundField DataField="firstName" HeaderText="Discription" SortExpression="firstName">
                            <ItemStyle Width="20%" />
                        </asp:BoundField>  
                     </Columns>       
                </asp:GridView>                                                              
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Price 2">
            <ItemTemplate>
                <asp:Label ID="lblPriceTwo" runat="server" Text='test2'></asp:Label>
                <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" 
                    AutoGenerateDeleteButton="False" AutoGenerateEditButton="False">
                     <Columns>
                        <asp:BoundField DataField="lastName" HeaderText="lastName" SortExpression="lastName">
                            <ItemStyle Width="20%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="firstName" HeaderText="Discription" SortExpression="firstName">
                            <ItemStyle Width="20%" />
                        </asp:BoundField>                        
                     </Columns>       
                </asp:GridView> 
            </ItemTemplate>
        </asp:TemplateField>        

        <asp:TemplateField HeaderText="">
            <ItemTemplate>
               <asp:Button ID="btnShow" runat="server" Text="Expand" CommandName="Show" CommandArgument='<%# Container.DataItemIndex%>' />
            </ItemTemplate>
        </asp:TemplateField>

        </Columns>

    </asp:GridView>
    </div>
    </form>
</body>
</html>
4

1 回答 1

1

有一篇文章可能有用:

http://www.codeproject.com/Articles/249155/Rows-and-Columns-Merging-in-ASP-NET-GridView-Contr

于 2013-02-07T13:11:23.813 回答