应该可以,用两个datalist嵌套
解决方案 »
- 【求助】谁有定时的导出数据库表到EXCEL中备份,代码或方法?
- 页面按纽无法保存状态?
- 为什么总要这样?
- CSDN有没有一个真正的高手!C#插入照片到excel的问题。
- 关于frame框架的简单问题
- asp.net girdview 鼠标悬停,分页后问题
- 急--如何判断某请求的类别是在"IE的地址栏输入"的还是"通过页面link(a href="")或 Response.Redirect发出的??
- 新增数据问题!!
- 页面跳转控制,请各位帮忙!
- 用ASP.NET+C# 连SQL SERVER, 为什么总System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝
- 请高手 帮忙看看 会是什么问题
- 如何用CustomValidator来验证listbox
{
// ÔÚ´Ë´¦·ÅÖÃÓû§´úÂëÒÔ³õʼ»¯Ò³Ãæ
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,"×Öĸ")%>
</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>
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