GridView中 绑定了一个主表 每行显示不同的主表记录  现在又要在该GridView中显示子表记录   而且每个子表记录显示在对应主表记录的下一行            也就是说两行为一组 第一行是主表记录 第二行是子表记录         用什么方法呢     

解决方案 »

  1.   

    用GridView控件做比较麻烦
    建议用Repeter控件
      

  2.   

    恩 知道啊   之前的都是用GridView  样式表什么的都是根据那个来的       如果改成Repeter要改的地方简直不敢想象啊
      

  3.   

    嵌套,GridView里面放一层Repeter或者ListView,或者再嵌套一个GridView都行。样式表引进来,哪个控件应该都可以用吧,把Class属性设置一下不就成了吗。
      

  4.   

    哦 我用的是<Anthem:GridView> 这个控件 不是<jsp:GridView>
      

  5.   

    1、建立一个类,public class MultTitle
    {
     public MultTitle()
     {
      //
      // TODO: 在此处添加构造函数逻辑
      //
     }//title 为一个自定义的Titles类数组,其有两个属性,一个为Span:要合并的列数;一个是text:单元格中内容。关于Titles类请自己定义,很容易的。
        public static void createTitle(object sender, GridViewRowEventArgs e,Titles[] title)
        {
            YYControls.SmartGridView grid=((YYControls.SmartGridView) sender);
            GridViewRow rowHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);//建立一个新行。
            TableCellCollection cells = e.Row.Cells;//得到原来的标题行。
            rowHeader.CssClass = "userHeaderRows";//标题行的样式
            int sumCol = 0;//用于记录原标题行的当前单元格号。
            for (int col = 0; col < title.Length; col++)
            {
                TableCell headerCell = new TableCell();
                headerCell = new TableCell();
                headerCell.Text = title[col].text;
                headerCell.HorizontalAlign = HorizontalAlign.Center;
                headerCell.VerticalAlign = VerticalAlign.Middle;
                headerCell.ColumnSpan = title[col].span;//合并左右相邻的单元格
                if (title[col].span == 1)//如果列是1列,即不合并单元格,则就要合并上下单元格。
                {
                    cells.RemoveAt(sumCol);//删除原标题行的与当前单元格对应的单元格。
                    sumCol = sumCol - 1;//原标题当前单元格减1,因为上面删除了1个单元格。
                    headerCell.RowSpan = 2;//合并上下个单元格。
                }
                sumCol = sumCol + title[col].span;//计算原标题行的当前单元格
                rowHeader.Cells.Add(headerCell);//增加一个单元格
            }
            rowHeader.Visible = true;//显示行
            grid.Controls[0].Controls.AddAt(0, rowHeader);//增加到原标题行前面
        }
    }2、在GridView中的RowCreate事件中调用上面的类即可实现GridView的多标题行。
      

  6.   

    gridview前提绑定数据
    或通过JS控制DIV显示信息,点击实现显示和隐藏子表数据
      

  7.   

    [b]不要这么麻烦了  就问 如何用gridview如何多行显示一条记录  似乎这个解决了就可以解决问题了[/b
      

  8.   

    <asp:DataList ID="DataList1" runat="server" Width="100%"
                    onitemdatabound="DataList1_ItemDataBound" 
                    oneditcommand="DataList1_EditCommand">
                    <HeaderTemplate>
                    <table class="Query">
                    </HeaderTemplate>
            <ItemTemplate>
            <tr style=" height:25px;">
               <td style="width:120px; text-align:center; background-color:Black;color:White;">订单号</td>
               <td style="text-align:center;background-color:Black;color:White;">下单客户</td>
               <td style="width:100px;text-align:center; background-color:Black;color:White;">下单日期</td>
               <td style=" width:60px;text-align:center; background-color:Black;color:White;">状态</td>
               <td style=" width:60px;text-align:center; background-color:Black;color:White;"></td>
               </tr>
               <tr style=" height:20px;">
               <td style="width:120px;text-align:center; background-color:White;"><%# DataBinder.Eval(Container.DataItem,"NetOrderNo")%></td>
               <td style="text-align:center; background-color:White;"><a href='../Customer/CustomerInformation.aspx?id=<%# DataBinder.Eval(Container.DataItem,"CustomerID")%>' target="_blank"><%# Eval("CustomerName")%></a></td>
               <td style="width:100px;text-align:center; background-color:White;"><%# string.Format("{0:yyyy.MM.dd}",Eval("NetOrderDate"))%></td>
               <td style="width:60px;text-align:center; background-color:White;"><%#(HRManage.NetOrder.Consts.NET_ORDER_STATE)((byte)Eval("NetOrderState"))%></td>
               <td style=" width:60px;text-align:center; background-color:White;"><asp:LinkButton ID="lbAllSend" CommandName="Edit" runat="server">全部发货</asp:LinkButton></td>
               </tr>
               <tr>
               <td colspan="5" style="background-color:White;">
               <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" 
                CellPadding="4" ForeColor="Black" GridLines="Vertical"  Width="100%" 
                onrowdeleting="GridView1_RowDeleting" 
                    onrowdatabound="GridView1_RowDataBound" >
                <RowStyle BackColor="#F7F7DE" />
                <Columns>
                <asp:BoundField HeaderText="商品名称" HeaderStyle-Width="300px" DataField="GoodsName" ReadOnly="true" />
                <asp:BoundField HeaderText="下单数量" DataField="GoodsNum" HeaderStyle-Width="60px" ReadOnly="true" />
                <asp:BoundField HeaderText="发货记录" DataField="DeliveryRecords" ReadOnly="true" />
                <asp:TemplateField>
                  <ItemTemplate>
                    <asp:LinkButton ID="lbDelete" runat="server" CommandName="Delete" CausesValidation="false">发货</asp:LinkButton>
                  </ItemTemplate>
                  <HeaderStyle Width="35px" />
                  <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#CCCC99" />
                <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                <SelectedRowStyle BackColor="#CE5D5A" ForeColor="White" />
                <HeaderStyle BackColor="#6B696B" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
               </td>
               </tr>
            </ItemTemplate>
            <FooterTemplate>
            </table>
            </FooterTemplate>
        </asp:DataList>