应该可以,用两个datalist嵌套

解决方案 »

  1.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    // ÔÚ´Ë´¦·ÅÖÃÓû§´úÂëÒÔ³õʼ»¯Ò³Ãæ
    DataSet ds = new DataSet();
    DataTable dtbl = ds.Tables.Add("pinyin"); DataRow dr;
    dtbl.Columns.Add("拼音", typeof(string));
    char c = 'A';
    while(c<='Z')
    {
    dr = dtbl.NewRow();
    dr[0] = c.ToString();
    dtbl.Rows.Add(dr);
    c++;
    }
    SqlConnection conn = new SqlConnection("server=***;uid=***;pwd=;database=***;");
    SqlDataAdapter dad = new SqlDataAdapter("select * from people where field='"+Request.QueryString["field"]+"'", conn);
    dad.Fill(ds, "stars"); ds.Relations.Add("myrelation", ds.Tables["pinyin"].Columns["拼音"],ds.Tables["stars"].Columns["pinyin"]);

    DataList1.DataSource = ds.Tables["pinyin"];
    DataList1.DataBind();
    }
    <asp:datalist id="DataList1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"
    BorderColor="White" BorderStyle="Ridge" CellSpacing="1" BackColor="White" CellPadding="3"
    BorderWidth="2px">
    <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle>
    <ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle>
    <ItemTemplate>
    <asp:Label id="Label1" runat="server">
    <%# DataBinder.Eval(Container.DataItem,"×&Ouml;&Auml;&cedil;")%>
    </asp:Label>
    <asp:DataList id=DataList2 runat="server" DataSource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>' RepeatDirection="Horizontal">
    <SeparatorStyle ForeColor="Aqua"></SeparatorStyle>
    <ItemTemplate>
    <asp:HyperLink ID="HyperLink1" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "[\"starsname\"]", "stars.aspx?starsname={0}")%>' Runat="server">
    <%# DataBinder.Eval(Container.DataItem, "[\"starsname\"]")%>
    </asp:HyperLink>
    </ItemTemplate>
    <SeparatorTemplate>
    </SeparatorTemplate>
    </asp:DataList>
    </ItemTemplate>
    <FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
    <HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle>
    </asp:datalist>
      

  2.   

    VB的 很简单 并行那个文档很多 自己处理一下吧
    Sub FillGrids(ByVal UsrID As String)
            Dim aDS As DataSet = aFun.GetDS("select * from MainTable")
            Dim i As Integer = 0
            Dim aRow As DataRow
            For Each aRow In aDS.Tables(0).Rows
                i += 1
                Dim aGrid As New DataGrid
                aGrid.ID = "aGrid" & i.ToString
                aGrid.Width = Unit.Percentage(100)            Dim aView As DataView = GetTable("select * from SubTable Where RelatedID=" & aRow.Item("ForeignKey"))            If aView.Count > 0 Then
                    Page.Controls.Add(aGrid)
                    aGrid.DataSource = aView
                    aGrid.DataBind()
                    aGrid.Controls(0).EnableViewState = False
                End If
            Next
    End Sub