2011-03-09 38 views
1

我正在使用一個網頁並使用一個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不存在

+2

嵌套在DataList在另一個頁面上的控制?是ID dlConcerts0還是dlConcerts? – 2011-03-09 07:27:32

+0

你需要發佈完整的代碼,以便我們可以幫助你。 – 2011-03-09 07:32:18

+0

作爲一種良好的編程習慣,請確保您的事件處理程序名稱符合您的標識。當前示例列出了ID = dlConcerts0作爲您的事件處理程序以dlConcerts開頭...請檢查標識... – sajoshi 2011-03-09 07:36:33

回答

0

你必須從你的上DataList控件一樣找到你的DataList控件..

DataList dl = (DataList)dlConcerts.FindControl("dlConcerts0"); 
相關問題