2013-04-27 2 views
1

OnItemCommand가있는 repeater에서 LinkButton을 트리거하려고합니다. 그러나이 페이지는 다시 게시됩니다. 여기 내 코드는 다음과 같습니다.updatepanel가 repeater itemcommand를 트리거하지 않습니다.

<asp:UpdatePanel ID="recommendedAdvertsUpPnl" runat="server"> 
    <ContentTemplate> 
     <div class="tagList">  
      <asp:Label ID="lbListBookType" runat="server"></asp:Label> 
      <asp:Repeater ID="rpRecommendedAdvertFacultyList" runat="server" OnItemDataBound="rpRecommendedAdvertFacultyList_ItemDataBound" OnItemCommand="rpRecommendedAdvertFacultyList_ItemCommand"> 
       <HeaderTemplate></HeaderTemplate> 
       <ItemTemplate> 
        <asp:LinkButton ID="lbtnAdvertFaculty" runat="server" CommandArgument='<%#Eval("facultyId") %>' CommandName="selectFaculty" CssClass="advertFacultySelection"></asp:LinkButton> 
       </ItemTemplate> 
       <FooterTemplate></FooterTemplate> 
      </asp:Repeater>   
     </div> 
    <div class="RecommendedAdverts_List"> 
    <asp:Repeater ID="rpRecommendedAdvertList" runat="server" OnItemDataBound="rpRecommendedAdvertList_ItemDataBound"> 
     <HeaderTemplate> 
      <ul class="content_recommended"> 
     </HeaderTemplate> 
     <ItemTemplate> 
      <%# Container.ItemIndex % 4 == 0 ? "<li><div class=advertContainer>": String.Empty%> 
      <div class="advertPanel"> 
       <div class="rAdvPanel"> 
        <div class="advertPic"><asp:Panel ID="pnlRecAdvertPic" runat="server"></asp:Panel></div> 
        <div class="advertInfoPanel"> 
         <a href="../../IlanDetay/<%#Eval("Book.name") %>/<%#Eval("id") %>"><%#Eval("Book.Name")%></a> <br /> 
         <%#Eval("Book.Authors")%><br /> 
         <%#Eval("Price")%> TL<br /> 
        </div> 
       </div> 
      </div> 
     <%# Container.ItemIndex % 4 == 3 ? "</div></li>": String.Empty%> 
     </ItemTemplate> 
     <FooterTemplate> 
       </div></li> 
      </ul> 
     </FooterTemplate> 
    </asp:Repeater> 
    </div> 
    </ContentTemplate> 
    <Triggers> 
     <asp:AsyncPostBackTrigger ControlID="rpRecommendedAdvertFacultyList" EventName="ItemCommand" /> 
    </Triggers> 

</asp:UpdatePanel> 

트리거링을 제외하고는 아무런 문제가 없습니다.

protected void rpRecommendedAdvertFacultyList_ItemDataBound(object sender, RepeaterItemEventArgs e) 
{ 
    if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) 
    { 
     AdvertFacultyInfo item = (AdvertFacultyInfo)e.Item.DataItem; 
     LinkButton lbtnAdvertFaculty = (LinkButton)e.Item.FindControl("lbtnAdvertFaculty"); 

     lbtnAdvertFaculty.Text = item.Faculty.name;    
    } 
} 

protected void rpRecommendedAdvertFacultyList_ItemCommand(object source, RepeaterCommandEventArgs e) 
{   
    switch (e.CommandName) 
    { 
     case "selectFaculty": 
      List<AdvertFacultyInfo> advFacultyInfoList = EntitiyProvider.GetAdvertFacultyInfoListByFacultyId(Convert.ToInt32(e.CommandArgument)); 
      List<Advert> selectedList = new List<Advert>(); 
      foreach (AdvertFacultyInfo item in advFacultyInfoList) 
      { 
       Advert currentAdv = this.recommendedAdvertList.FirstOrDefault(i => i.id == item.advertId); 
       if (currentAdv != null) 
       { 
        selectedList.Add(currentAdv); 
       } 
      } 
      rpRecommendedAdvertList.DataSource = selectedList; 
      rpRecommendedAdvertList.DataBind(); 

      ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>$('.content_recommended').quickPager()</script>", false); 
      break; 

     default: 
      break; 
    } 
} 

나는 또한이 코드를 시도 : 다음은 내 서버 측 코드는하지만 같은 오류를 제공 lbtnAdvertFaculty I 대해 서면을 많이 연구 한

<asp:AsyncPostBackTrigger ControlID="lbtnAdvertFaculty" EventName="Click" /> 

찾아 could'nt 이 문제가 있지만 유용한 예제와 솔루션을 찾을 수 없습니다.

좋습니다.

답변

0

@Page 지시문에 ClientIDMode = "AutoID"를 넣으십시오.

관련 문제