|
DataList嵌套的重点是要在外层DataList的ItemDataBound事件中用e.Item.FindControl方法来找到嵌套层DataList的id,编写嵌套层DataList的绑定数据源事件,具体代码如下: '--------前台代码DLNested.aspx:
<%@ Page language="c#" Codebehind="DLNested.aspx.cs" AutoEventWireup="false" Inherits="Example.DateListNested" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>DateListNested</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <style type="text/css">TD { FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: "宋体" } </style> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" cellSpacing="1" cellPadding="1" width="100%" border="1" bordercolordark=white> <tr> <td><a href="Default.aspx">DataList分页、编辑实例</a></td> </tr> <TR> <TD> <asp:DataList id="DataList1" runat="server" RepeatColumns="3"> <ItemTemplate> <FONT face="宋体"> <TABLE cellSpacing="1" cellPadding="1" width="100%" border="1" bordercolordark=white> <TR> <TD><FONT face="宋体" color="red"> <asp:Label id=Label1 runat="server" Text='<%# Container.ItemIndex + ":" + DataBinder.Eval(Container.DataItem,"C_TypeName")%>' > </asp:Label> <asp:Label id="lblTypeId" runat="server" Visible=False Text='<%# DataBinder.Eval(Container.DataItem,"I_TypeID")%>' >
上一篇:DataList分页、增加、删除、修改实例
下一篇:ComponentOne之WebChart用法
|