在当前上下文中找不到datalist

时间:2011-03-09 07:25:53

标签: c# .net asp.net datalist

我正在使用网页并使用datalist控件。

  <%@ Page Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true" CodeFile="Concerts.aspx.cs"
    Inherits="Default2"  %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct="UA-15707367-1";
urchinTracker();

</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <%= strModuleName%>
    <asp:UpdatePanel ID="upUpdateConcert" runat="server">
        <ContentTemplate>
            <div class="LeftContaionerTopTextStyle">
              <asp:LinkButton ID="lnkConcert" CssClass="LeftContainerHeaderText" runat="server" OnClick="lnkConcert_Click">Concerts & Tickets</asp:LinkButton><br />
                <asp:LinkButton ID="lnkTickets" CssClass="Link" runat="server" OnClick="lnkConcert_Click">Ticket Policies </asp:LinkButton><br />
                 <asp:LinkButton ID="lnkSeating" CssClass="Link" runat="server" OnClick="lnkConcert_Click">Seating Chart</asp:LinkButton><br />
                <asp:LinkButton ID="lnkGroup" CssClass="Link" runat="server" OnClick="lnkConcert_Click">Group Sales </asp:LinkButton><br />
                <asp:LinkButton ID="lnkDirection" CssClass="Link" runat="server" OnClick="lnkConcert_Click">Directions & Parking</asp:LinkButton><br />


            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <%-- DATALIST FOR CONCERT TITLE AND IMAGE --%> 
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="RightContainerHeaderText">
        <%#Eval("ConcertTitle") %>
        </div>
          <div class="RightContainerText">
            <div class="HomeLeftPanel">
                <%-- DATALIST FOR CONCERT DATE IMAGE --%>
                <asp:DataList ID="dlConcerts" runat="server" OnItemDataBound="dlConcerts_ItemDataBound"
                    RepeatColumns="1" OnItemCommand="dlConcerts_ItemCommand" RepeatDirection="Vertical" 
                    >
                    <ItemTemplate>
<div id="divHr" runat="server" class="DivHRConcerts">


                        <div class="DivInnerHRConcerts">

                            2010-2012 Concert Season

                        </div>

                                    </div>

                        <div class="LeftConcertsContainer">
                            <div class="LeftConcertsImageContainer">
                                <img src='ConcertImages/<%#Eval("ConcertImage") %>' alt='<%#Eval("ConcertImage") %>'
                                    title='<%#Eval("ConcertImage") %>' />
                            </div>
                            <div class="LeftConcertsHeading">
                                <span class="HeadingGreen">
                                    <%#Eval("ConcertTitle") %></span><br />
                                <%-- DATALIST FOR CONCERT DATE IMAGE --%>
                                <asp:DataList ID="dlConcertDates" runat="server">
                                    <ItemTemplate>
                                        <span class="ConcertsTime">
                                            <%#Eval("ConcertDate") %></span>
                                    </ItemTemplate>
                                </asp:DataList>
                            </div>
                            <div class="ConcertsLeftTextArea">
                                <%-- DATALIST FOR CONCERT GUESTS IMAGE --%>
                                <asp:DataList ID="dlConcertGuests" runat="server" RepeatColumns="1" RepeatDirection="Vertical">
                                    <ItemTemplate>
                                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                            <tr>
                                                <td>
                                                    <%#Eval("GuestName") %><span>, </span><%#Eval("InstrumentName") %>
                                                </td>
                                            </tr>
                                        </table>
                                    </ItemTemplate>
                                </asp:DataList>
                            </div>
                            <div class="ConcertsRightTextContainer">
                                <div class="ConcertsRightTextArea">
                                    <%-- DATALIST FOR CONCERT REPERTORIE IMAGE --%>
                                    <asp:DataList ID="dlRepetoire" runat="server" RepeatColumns="1" RepeatDirection="Vertical">
                                         <HeaderTemplate>
                                                        <table cellpadding="0" cellspacing="0" border="0" width="212px">
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td valign="top" style="width:90px">
                                                                <%#Eval("RepertoireName") %>
                                                                &nbsp;
                                                            </td>
<td style="width:10px">
&nbsp;
</td>
                                                            <td valign="top">
                                                                <%#Eval("RepertoireTitle")%>
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                    <FooterTemplate>
                                                        </table></FooterTemplate>
                                    </asp:DataList>
                                </div>



                                <div class="ConcertsButtonContainer" >
                                <div class="LearnMoreButton" ><a href="Content.aspx?ModuleID=63">
                                                        <img src="Images/SubscribeButton.jpg" border="0" /></a></div>
<div class="OrderTicketsButton" id="div1" runat="server"><asp:ImageButton ID="btnLearnMore" ImageUrl="Images/LearnMore.jpg" CommandArgument='<%#Eval("ConcertID") %>'
                                                    CommandName="LearnMore" Width="94" Height="19" runat="server" />
                                                    </div>
                                <div class="OrderTicketsButton" id="divSingleTicket" runat="server">
                                  <div id="sddm"  onmouseover="mopen('<%#Eval("ConcertID") %>')"
                                        onmouseout="mclosetime()">
                                        <img src="Images/OrderTickets.jpg" id="imgOrder" style="cursor: pointer;" runat="server"
                                            width="111" height="19" /><br />
                                        <div id='<%#Eval("ConcertID") %>' onmouseover="mcancelclosetime();" onmouseout="mclosetime()">
                                            <table id="tableProjectList" runat="server" cellpadding="0" cellspacing="0" border="0">
                                            </table>
                                        </div>
                                    </div>
                                </div>

                                </div>
                                <div class="SubscribeButton" id="divSubscribe" runat="server" >
                                <asp:ImageButton ID="btnLearnMore1" ImageUrl="Images/LearnMore.jpg" CommandArgument='<%#Eval("ConcertID") %>'
                                                    CommandName="LearnMore" Width="94" Height="19" runat="server" />
                                </div>

                            </div>
                        </div>
                        <div class="DotImage">
                        </div>
                    </ItemTemplate>
                </asp:DataList>

            </div>

                <asp:DataList ID="dlConcerts0" runat="server" OnItemDataBound="dlConcerts_ItemDataBound"
                    RepeatColumns="1" OnItemCommand="dlConcerts_ItemCommand" RepeatDirection="Vertical" 
                    >
                    <ItemTemplate>
<div id="divHr0" runat="server" class="DivHRConcerts">


                        <div class="DivInnerHRConcerts">

                            2011-2012 Concert Season

                        </div>

                                    </div>

                        <div class="LeftConcertsContainer">
                            <div class="LeftConcertsImageContainer">
                                <img src='ConcertImages/<%#Eval("ConcertImage") %>' alt='<%#Eval("ConcertImage") %>'
                                    title='<%#Eval("ConcertImage") %>' />
                            </div>
                            <div class="LeftConcertsHeading">
                                <span class="HeadingGreen">
                                    <%#Eval("ConcertTitle") %></span><br />
                                <%-- DATALIST FOR CONCERT DATE IMAGE --%>
                                <asp:DataList ID="dlConcertDates" runat="server">
                                    <ItemTemplate>
                                        <span class="ConcertsTime">
                                            <%#Eval("ConcertDate") %></span>
                                    </ItemTemplate>
                                </asp:DataList>
                            </div>
                            <div class="ConcertsLeftTextArea">
                                <%-- DATALIST FOR CONCERT GUESTS IMAGE --%>
                                <asp:DataList ID="dlConcertGuests" runat="server" RepeatColumns="1" RepeatDirection="Vertical">
                                    <ItemTemplate>
                                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                            <tr>
                                                <td>
                                                    <%#Eval("GuestName") %><span>, </span><%#Eval("InstrumentName") %>
                                                </td>
                                            </tr>
                                        </table>
                                    </ItemTemplate>
                                </asp:DataList>
                            </div>
                            <div class="ConcertsRightTextContainer">
                                <div class="ConcertsRightTextArea">
                                    <%-- DATALIST FOR CONCERT REPERTORIE IMAGE --%>
                                    <asp:DataList ID="dlRepetoire" runat="server" RepeatColumns="1" RepeatDirection="Vertical">
                                         <HeaderTemplate>
                                                        <table cellpadding="0" cellspacing="0" border="0" width="212px">
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td valign="top" style="width:90px">
                                                                <%#Eval("RepertoireName") %>
                                                                &nbsp;
                                                            </td>
<td style="width:10px">
&nbsp;
</td>
                                                            <td valign="top">
                                                                <%#Eval("RepertoireTitle")%>
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                    <FooterTemplate>
                                                        </table></FooterTemplate>
                                    </asp:DataList>
                                </div>



                                <div class="ConcertsButtonContainer" >
                                <div class="LearnMoreButton" ><a href="Content.aspx?ModuleID=63">
                                                        <img src="Images/SubscribeButton.jpg" border="0" /></a></div>
<div class="OrderTicketsButton" id="div2" runat="server"><asp:ImageButton ID="btnLearnMore" ImageUrl="Images/LearnMore.jpg" CommandArgument='<%#Eval("ConcertID") %>'
                                                    CommandName="LearnMore" Width="94" Height="19" runat="server" />
                                                    </div>
                                <div class="OrderTicketsButton" id="divSingleTicket0" runat="server">
                                  <div id="sddm0"  onmouseover="mopen('<%#Eval("ConcertID") %>')"
                                        onmouseout="mclosetime()">
                                        <img src="Images/OrderTickets.jpg" id="imgOrder0" style="cursor: pointer;" runat="server"
                                            width="111" height="19" /><br />
                                        <div id='<%#Eval("ConcertID") %>0' onmouseover="mcancelclosetime();" 
                                            onmouseout="mclosetime()">
                                            <table id="tableProjectList0" runat="server" cellpadding="0" cellspacing="0" 
                                                border="0">
                                            </table>
                                        </div>
                                    </div>
                                </div>

                                </div>
                                <div class="SubscribeButton" id="divSubscribe0" runat="server" >
                                <asp:ImageButton ID="btnLearnMore1" ImageUrl="Images/LearnMore.jpg" CommandArgument='<%#Eval("ConcertID") %>'
                                                    CommandName="LearnMore" Width="94" Height="19" runat="server" />
                                </div>

                            </div>
                        </div>
                        <div class="DotImage">
                        </div>
                    </ItemTemplate>
                </asp:DataList>

        </div>

</asp:Content>

当我用它编码然后它给出错误dlConcerts0不存在

1 个答案:

答案 0 :(得分:0)

你必须从上面的DataList控件中找到你的DataList控件,比如..

DataList dl = (DataList)dlConcerts.FindControl("dlConcerts0");