MyException - 我的异常网
当前位置:我的异常网» C# » [WebForm]DataList里面如果再有一个DataList,两个数

[WebForm]DataList里面如果再有一个DataList,两个数据源都是通过DAL层传出来的,现在不知道子DataList的DataBind()方法怎么调用

www.MyException.Cn  网友分享于:2013-12-22  浏览:14次
[WebForm]DataList里面如果再有一个DataList,两个数据源都是通过DAL层传出来的,现在不知道子DataList的DataBind()方法如何调用。
C# code

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;

namespace TestWeb
{
    public partial class _Default : System.Web.UI.Page
    {
        private BLL.Bll bll = new Bll();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataBindQuestionDataList();
            }
        }

        /// <summary>
        /// 绑定问题list控件
        /// </summary>
        private void DataBindQuestionDataList()
        {
            this.DataList1.DataSource = bll.SearchQuestion();
            this.DataList1.DataBind();
        }

        public DataSet BindReply(Guid id)
        {
            return bll.SearchReply(id);
        }

        protected void dlReply_Load(object sender, EventArgs e)
        {
            
        }
    }
}



页面代码
HTML code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWeb._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>
</head>
<body>
    <form id="form1" runat="server">
        <table border="0" width="100%" cellpadding="1" cellspacing="1">
            <tr>
                <td>
                    <label>问题主旨:</label>
                        <asp:Label ID="labSubject" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td><asp:DataList ID="DataList1" runat="server" >
                    <ItemTemplate>
                        <table border="0" cellpadding="1">
                            <tr>
                                <td style="width:60px">
                                    <asp:Label ID="labTitle" runat="server" Text="问题:"></asp:Label>
                                </td>
                                <td style="width:340px">
                                    <asp:Label ID="labQuestion" runat="server" Text='<%# Bind("Content") %>'></asp:Label>
                                </td>
                                <td style="width: 60px">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:DataList ID="dlReply" runat="server" DataSource='<%# BindReply((Guid)DataBinder.Eval(Container,"DataItem.CvsCmtID")) %>' OnLoad="dlReply_Load">
                                        <ItemTemplate>
                                            <table border="0" >
                                                <tr>
                                                    <td>
                                                        <label>回覆:</label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="labReplyContent" runat="server" Text='<%# Bind("ReplyContent") %>' ></asp:Label>
                                                    </td>
                                                    <td>
                                                    </td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                    </asp:DataList>
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:DataList>
                </td>
                
            </tr>
            <tr>
                
                <td>
                    <label>通知记录:</label>
                    
                </td>
            </tr>
        </table>
    </form>
</body>
</html>


文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有