Datalist巢狀
前臺程式碼
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dDataList.aspx.cs" Inherits="movie_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標題頁</title>
<link href="../CSS/CSS.css" rel="stylesheet" type="text/css" />
<link href="../CSS/play.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style1
{
width: 89px;
}
.style2
{
width: 97px;
}
</style>
</head>
<body>
<form id="form1">
<div style="text-align: left">
<asp:DataList ID="DataList1" runat="server"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<div style="height: 158px; width: 939px;">
<table style="width:101%; height: 154px;">
<tr>
<td class="style1" rowspan="4">
<a href='<%# "listmovie.aspx?id="+Eval("mid")%>'><img alt="" src="<%#Eval("image") %>"
style="height: 150px; width: 120px" /></a><td class="style2">
名稱:<asp:Label ID="Label4" runat="server" Text='<%# Eval("title") %>'></asp:Label>
</td>
<td rowspan="4">
<div class="abcs_2">
<div class="movienews3c">
<asp:DataList ID="dlsProductInfo" runat="server" RepeatColumns="6"
RepeatDirection="Horizontal" Height="126px" Width="30px">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# "play.aspx?id="+Eval("mid")+"&number="+Eval("number") %>'
Text='<%# "第"+Eval("number")+"集" %>'></asp:HyperLink>
</ItemTemplate>
</asp:DataList>
</div>
</div>
</td>
</tr>
<tr>
<td class="style2">
時間:<asp:Label ID="Label1" runat="server" Text='<%# Eval("datetime","{0:yyyy-MM-dd}") %> '></asp:Label>
</td>
</tr>
<tr>
<td class="style2">
型別:<asp:Label ID="Label3" runat="server" Text='<%# Eval("leixin") %>'></asp:Label>
</td>
</tr>
<tr>
<td class="style2">
簡介:<asp:Label ID="Label5" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"jianjie").ToString().Length>15?DataBinder.Eval(Container.DataItem,"jianjie").ToString().Substring(0,15)+"...":DataBinder.Eval(Container.DataItem,"jianjie").ToString() %>'></asp:Label>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
後臺程式碼
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class movie_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ComFunction cf = new ComFunction();
DataSet ds = cf.DataBind("M_title");
DataList1.DataSource = ds;
DataList1.DataBind();
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataList dataList = (DataList)e.Item.FindControl("dlsProductInfo");
DataRowView rowv = (DataRowView)e.Item.DataItem;
string mainID = Convert.ToString(rowv["mid"]);
if (mainID!="")
{
ComFunction cf = new ComFunction();
DataSet ds = cf.BindOneField("M_dizhi", "mid", mainID);
if (ds != null)
{
try
{
dataList.DataSource = ds;
dataList.DataBind();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}
}
}
相關文章
- 巢狀使用 datalist (轉)巢狀
- less巢狀巢狀
- 集合框架-集合的巢狀遍歷(HashMap巢狀HashMap)框架巢狀HashMap
- 集合框架-集合的巢狀遍歷(HashMap巢狀ArrayList)框架巢狀HashMap
- 集合框架-集合的巢狀遍歷(ArrayList巢狀HashMap)框架巢狀HashMap
- 集合框架-集合的巢狀遍歷(多層巢狀)框架巢狀
- vue路由巢狀Vue路由巢狀
- angular 巢狀路由Angular巢狀路由
- 迴圈_巢狀巢狀
- 集合的巢狀巢狀
- 盒子的巢狀巢狀
- oracle巢狀表Oracle巢狀
- Oracle 巢狀表Oracle巢狀
- 列表巢狀操作巢狀
- Locust 任務巢狀巢狀
- Oracle 巢狀表(轉)Oracle巢狀
- 巢狀子查詢巢狀
- vue(19)巢狀路由Vue巢狀路由
- SCSS 巢狀屬性CSS巢狀
- SCSS 巢狀規則CSS巢狀
- Blazor巢狀傳遞Blazor巢狀
- 巢狀動畫如何使用巢狀動畫
- java介面巢狀【Z】Java巢狀
- iterate的巢狀使用巢狀
- 巢狀類遞迴巢狀遞迴
- 展開巢狀列表巢狀
- MySQL Join原理分析(緩衝塊巢狀與索引巢狀迴圈)MySql巢狀索引
- PLSQL Language Referenc-巢狀表-巢狀表和陣列間的重要區別(正確地使用巢狀表)SQL巢狀陣列
- nginx 如何實現 if 巢狀Nginx巢狀
- html的巢狀規則HTML巢狀
- vue-router 巢狀路由Vue巢狀路由
- 【Qt6】巢狀 QWindowQT巢狀
- vue巢狀元件傳參Vue巢狀元件
- 封裝多型巢狀封裝多型巢狀
- iOS多重巢狀頁面iOS巢狀
- JavaScript字串引號巢狀JavaScript字串巢狀
- Python 迴圈巢狀Python巢狀
- DAG模型——巢狀矩陣模型巢狀矩陣