2012-09-29 29 views
0

我有兩個嵌套的更新面板我更新源代碼的面板,但沒有任何效果。代碼如下updatepanel.update問題

<div style="display:block; clear: left;" runat="server" id="DivLike"> 
    <asp:UpdatePanel ID="UpdatePanelLike" runat="server" UpdateMode="Conditional"> 
     <ContentTemplate> 
      <div style="position: relative;"> 
       <div style="position: absolute; top: 0px; left: 0px;"> 
        <asp:LinkButton ID="LinkButtonLike" runat="server" CommandName='<%#Eval("Like_Command") %>' 
        Font-Size="XX-Small" OnCommand="LinkButton2_Command" Text='<%#Eval("Like_Command")%>'></asp:LinkButton> 
       </div> 
       <div class="popupstyle" style="position:absolute; top:0px; left:0px; display:none;" 
       id="DivChapters" runat="server"> 
        <asp:UpdatePanel ID="UpdatePanelLinkActivity" runat="server" UpdateMode="Conditional"> 
         <ContentTemplate> 
          <div>Select Chapter: 
           <asp:DropDownList ID="DropDownListChapters" runat="server" 
           AutoPostBack="true" OnSelectedIndexChanged="DropDownListChapters_SelectedIndexChanged"></asp:DropDownList> 
          </div> 
          <div>Select Topic: 
           <asp:DropDownList ID="DropDownListTopics" runat="server"></asp:DropDownList> 
          </div> 
          <div> 
           <asp:LinkButton ID="LinkButtonAddLink" runat="server" OnCommand="LinkButtonAddLink_Command" 
           Text="Add" CssClass="UtilityClass"></asp:LinkButton> 
          </div> 
          <asp:UpdateProgress ID="UpdateProgressLinkActivity" runat="server" AssociatedUpdatePanelID="UpdatePanelLinkActivity" 
          DynamicLayout="True"> 
           <ProgressTemplate> 
            <div style=" position:absolute; top:50%; left:50%; background-color:white;" 
            id="divLoading"> 
             <img src="Images/loading25.gif" alt="Loading..." style="" /> 
            </div> 
           </ProgressTemplate> 
          </asp:UpdateProgress> 
         </ContentTemplate> 
         <Triggers> 
          <asp:AsyncPostBackTrigger ControlID="LinkButtonAddLink" EventName="Command" 
          /> 
         </Triggers> 
        </asp:UpdatePanel> 
       </div> 
      </div> 
     </ContentTemplate> 
     <Triggers> 
      <asp:AsyncPostBackTrigger ControlID="LinkButtonLike" EventName="Command" 
      /> 
     </Triggers> 
    </asp:UpdatePanel> 
</div> 

下面的代碼更新面板,但沒有面板更新。儘管當我用調試器分析它時,每件事都是完美的。

protected void DropDownListChapters_SelectedIndexChanged(object sender, EventArgs e) 
{ 
    DropDownList DDL = (DropDownList)sender; 
    DropDownListTopics.DataSource = ChapterDataAccess.GetUserTopics(Convert.ToInt32(DDL.SelectedItem.Value), new Guid(Membership.GetUser().ProviderUserKey.ToString())); 
    DropDownListTopics.DataTextField = "Name"; 
    DropDownListTopics.DataValueField = "Id"; 
    DropDownListTopics.DataBind(); 
    ListItem item=new ListItem ("topics","value"); 
    DropDownListTopics.Items.Add(item); 
    UpdatePanel thepanel= (UpdatePanel)DDL.Parent.Parent; 
    UpdatePanel theparentpanel=(UpdatePanel)DDL.Parent.Parent.Parent.Parent.Parent ; 
    theparentpanel.Update(); 
    thepanel.Update(); 


} 
+0

這段代碼在gridview的itemtemplate中。 – user1575229

+0

刪除更新面板,並嘗試查看是否有任何錯誤,則可能只使用一個更新面板 – Aristos

+0

如果出現錯誤會怎麼樣?使用嵌套面板不一定是一種選擇。 – user1575229

回答

0

我不認爲你是正確的訪問更新面板..

當UpdatePanel的不是封閉內的另一個內容佔位符,我覺得你可以直接訪問更新面板,而不是使用父找到它..

只需

UpdatePanelLinkActivity.Update(); 
UpdatePanelLike.Update() ; 

應該做的..

+0

嗨!如果我能做到這一點,我會很高興。它們在GridView Row裏面。在問題中,沒有提到它。 – user1575229

+0

當我使用調試器進行檢查時,我很好地獲得了更新面板,但是當應用更新時,沒有任何反應。 – user1575229