這篇文章將為大家詳細講解有關asp.net中怎么實現(xiàn)DataList與Repeater的嵌套綁定,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供鎮(zhèn)海網(wǎng)站建設、鎮(zhèn)海做網(wǎng)站、鎮(zhèn)海網(wǎng)站設計、鎮(zhèn)海網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、鎮(zhèn)海企業(yè)網(wǎng)站模板建站服務,10余年鎮(zhèn)海做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。具體如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs" Inherits="home" %>
home.aspx.cs
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 home : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { myCheck.IsLoginNonReturn(); if (!IsPostBack) { Bind_monitorTypeList(); } } protected void Bind_monitorTypeList() { string sql = "select monitor_type_id,monitor_type_name from monitor_type"; DbConn conn = new DbConn(); DataSet ds = conn.DataSet(sql,"monitor_type"); monitorTypeList.DataSource = ds.Tables[0]; monitorTypeList.DataBind(); ds.Dispose(); conn.Close(); } protected void monitorTypeList_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string monitor_type_id = ((DataRowView)e.Item.DataItem).Row["monitor_type_id"].ToString(); Repeater monitorConfigList = (Repeater)e.Item.FindControl("monitorConfigList"); if (monitorConfigList != null) { string sql = "select monitor_id,nonitor_name,plugpath from monitor where monitor_type_id=" + monitor_type_id; DbConn conn = new DbConn(); DataSet ds = conn.DataSet(sql, "monitor"); monitorConfigList.DataSource = ds.Tables[0]; monitorConfigList.DataBind(); ds.Dispose(); conn.Close(); } } } }
關于asp.net中怎么實現(xiàn)DataList與Repeater的嵌套綁定就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。