1

세 가지 중첩 수준을 사용하는 설치가 있습니다. Repeater는 CollapsiblePanelExtenders (작동하는)를 사용하고 각각 GridView를 포함합니다. 이들 각각은 다른 CollapsiblePanelExtender에 의해 제어되는 다른 GridView를 포함합니다. 이러한 내부 CollapsiblePanels는 clientState를 True로 설정 한 경우에만 확장 또는 축소 상태를 효과적으로 표시합니다. 그러나 예상대로 효과적으로 확장되거나 축소되지는 않습니다. 모든 것이 동적으로 바운드됩니다. 여기 중첩 된 Repeater 및 Gridview 설치의 CollapsiblePanelExtender가 작동하지 않습니다.

은 ...

<asp:Repeater ID="cat_repeater" runat="server"> 
    <ItemTemplate> 
    <asp:CollapsiblePanelExtender id="cat_cpExt" runat="server" TargetControlID="cat_pnl" CollapsedSize="0" Collapsed="false" CollapsedImage="collapsed.png" ExpandedImage="expanded.png" ExpandControlID="cpControl_pnl" CollapseControlID="cpControl_pnl" TextLabelID="cpControl_lbl" ImageControlID="cpControl_img" CollapsedText='<%#configCPText(eval("Title"), False)%>' ExpandedText='<%#configCPText(eval("Title"), True) %>' /> 
    <asp:Panel ID="cpControl_pnl" runat="server" Visible='<%#itemVisible(eval("ID"), "Recipients", "CategoryID") %>' CssClass="CPanelStyle"> 
     <asp:Image ID="cpControl_img" runat="server" ImageUrl="expanded.png" /> 
     <asp:Label ID="cpControl_lbl" runat="server" Text='<%#configCPText(eval("Title"), True) %>' CssClass="CPanelText" /> 
    </asp:Panel> 
    <asp:Panel ID="cat_pnl" runat="server"> 
     <asp:GridView ID="recipients_gv" runat="server" CssClass="GVStyle" HeaderStyle-CssClass="GVHeaderStyle" RowStyle-CssClass="GVItemStyle" AutoGenerateColumns="false" GridLines="none" AllowPaging="false"> 
     <Columns> 
      <asp:TemplateField HeaderText="Name" SortExpression="Last Name" ItemStyle-CssClass="GVNameStyle"> 
      <ItemTemplate> 
       <asp:Literal id="name_lit" runat="server" text='<%#formatNameText(eval("FirstName"), eval("LastName")) %>' /> 
      </ItemTemplate> 
      </asp:TemplateField> 
      <asp:TemplateField HeaderText="Gifts" ItemStyle-Width="500px"> 
      <ItemTemplate> 
       <asp:CollapsiblePanelExtender id="gifts_cpExt" runat="server" TargetControlID="gifts_pnl" CollapsedSize="0" Collapsed="true" CollapsedImage="collapsed.png" ExpandedImage="expanded.png" ExpandControlID="cpControl_pnl2" CollapseControlID="cpControl_pnl2" TextLabelID="cpControl_lbl2" ImageControlID="cpControl_img2" CollapsedText='<%#configGiftsCPText(eval("ID"), True)%>' ExpandedText='<%#configGiftsCPText(eval("ID"), False) %>' /> 
       <asp:Panel ID="cpControl_pnl2" runat="server" Visible='<%#itemVisible(eval("ID"), "Gifts", "RecipientID") %>'> 
       <asp:Image ID="cpControl_img2" runat="server" ImageUrl="collapsed.png" /> 
       <asp:Label ID="cpControl_lbl2" runat="server" Text='<%#configGiftsCPText(eval("ID"), False) %>' /> 
       </asp:Panel> 
       <asp:Panel ID="gifts_pnl" runat="server"> 
       <asp:GridView ID="gifts_gv" runat="server" DataKeyNames="ID" RowStyle-CssClass="GVInnerItemStyle" HeaderStyle-CssClass="GVInnerHeaderStyle" Gridlines="None" AutoGenerateColumns="false" AllowPaging="false" Width="475px"> 
        <Columns> 
        <asp:TemplateField ItemStyle-CssClass="GVInnerButtonItemStyle" HeaderText="Description"> 
         <ItemTemplate> 
         <asp:LinkButton ID="gift_lBtn" runat="server" Text='<%#eval("Description") %>' CommandName="Select" /> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField HeaderText="Complete" ItemStyle-Width="50px"> 
         <ItemTemplate> 
         <asp:CheckBox ID="giftComplete_cbx" runat="server" Checked='<%#eval("Complete") %>' /> 
         </ItemTemplate> 
        </asp:TemplateField> 
        </Columns> 
       </asp:GridView> 
       </asp:Panel> 
      </ItemTemplate> 
      </asp:TemplateField> 
     </Columns> 
     </asp:GridView> 
    </asp:Panel> 
    <br /> 
    </ItemTemplate> 
</asp:Repeater> 

마크 업입니다 ... 그리고 여기에 모든 것을 결합하는 코드이다 :의 GridView 중첩 된 두 수준에서

Protected Sub bindCategories() 

    Try 
     oCmd.Connection = oConn 
     oCmd.CommandType = CommandType.Text 

     strSQL = "SELECT * FROM Categories" 

     oCmd.CommandText = strSQL 
     oDA.SelectCommand = oCmd 

     oDA.Fill(oDTbl) 

     cat_repeater.DataSource = oDTbl 
     cat_repeater.DataBind() 

     For i As Integer = 0 To oDTbl.Rows.Count - 1 


      oCmd.Parameters.Clear() 
      inner_dTbl.Clear() 

      strSQL = "SELECT *, Title FROM Recipients INNER JOIN Categories on Recipients.CategoryID = Categories.ID WHERE CategoryID = @CategoryID ORDER BY LastName" 

      oParam = New SqlParameter 
      oParam.ParameterName = "CategoryID" 
      oParam.SqlDbType = SqlDbType.Int 
      oParam.Value = oDTbl.Rows(i)("ID") 
      oCmd.Parameters.Add(oParam) 

      oCmd.CommandText = strSQL 
      oDA.SelectCommand = oCmd 

      oDA.Fill(inner_dTbl) 

      Dim gv As GridView = CType(cat_repeater.Items(i).FindControl("recipients_gv"), GridView) 
      gv.DataSource = inner_dTbl 
      gv.DataBind() 

      For j As Integer = 0 To inner_dTbl.Rows.Count - 1 

       oCmd.Parameters.Clear() 
       gifts_dTbl.Clear() 

       strSQL = "SELECT * FROM Gifts WHERE RecipientID = @RecipientID ORDER BY Description" 

       oParam = New SqlParameter 
       oParam.ParameterName = "RecipientID" 
       oParam.SqlDbType = SqlDbType.Int 
       oParam.Value = inner_dTbl.Rows(j)("ID") 
       oCmd.Parameters.Add(oParam) 

       oCmd.CommandText = strSQL 
       oDA.SelectCommand = oCmd 

       oDA.Fill(gifts_dTbl) 

       Dim inner_gv As GridView = CType(gv.Rows(j).FindControl("gifts_gv"), GridView) 
       inner_gv.DataSource = gifts_dTbl 
       inner_gv.DataBind() 

       Dim cpExt As CollapsiblePanelExtender = CType(gv.Rows(j).FindControl("gifts_cpExt"), CollapsiblePanelExtender) 
       cpExt.Collapsed = True 
       cpExt.ClientState = True 

      Next 

     Next 
    Catch ex As Exception 
     Throw ex 
    End Try 

End Sub 

내가 성공적으로 사용했습니다 CollapsiblePanelExtenders을 전에는 문제없이 설정하고 clientState를 설정하지 않아도됩니다. 그러나 전에 repeater와 함께 CollapsiblePanelExtenders를 사용할 때는 clientState를 지정해야했습니다.

이 3 레벨 중첩 설정에서이 Extender가 작동하지 않는 이유는 누구 에게든 입력이 있습니까?

if (this.SupportsClientState) { 
    ScriptManager.RegisterHiddenField(this, this.ClientStateFieldID, this.SaveClientState()); 
    this.Page.RegisterRequiresPostBack(this); 
} 

이것은 AjaxControlToolkit 공간에서 public class ScriptControlBase에서이다 : 그것은 모든 논리를 작동하게하는 포스트 백을 필요로하기 때문에 그것이 필요한 것 이유처럼 보이는

답변

0

이다.

UpdatePanel에 이것을 배치하고 있습니까? Repeater에서 CPE를 사용하는 포스트 백이 발생합니까? 중계기에서 CPE를 시도한 이후로 잠시 동안 지켜 보았습니다. 코드를 확인하고 빌드하려면이 시점에서 설정하지 않았습니다.

클라이언트 측에서 완전히 무언가를 사용할 수없고 자바 스크립트를 사용하여 확장/축소 할 수없는 이유가 있습니까? 이러한 것들이 확장 될 때 동적으로 서버 측에서 데이터를로드합니까?

+0

현재 리피터 CPE에서 다시 게시를하고 있는지 알고 계십니까? – jcolebrand

+0

저는이 시점에서 UpdatePanel에이 중 하나를 넣지 않았습니다. (적어도 추가 할 계획 인 추가 기능을 위해 내부 GridView를 래핑 할 계획이었습니다.) Repeater에서 CPE를 사용하면 포스트 백이 발생하지 않습니다. CPE는 포스트 백을 인식합니다. 내 코드에 표시된 것처럼 모든 데이터는 CPE를 사용하여 컨트롤에 동적으로로드됩니다. CPE의 클라이언트 측 메소드를 사용하여 JavaScript 접근 방식을 시도 할 수 있습니다. 나는 그것을 내일 시도 할 것이다. – Zogglet

+0

그렇게하지 않는다면, 그냥 jQuery를 사용하고 그 id를 토글하는 방법을 살펴 보아라.하지만 그것은 까다로울 수있다. 내가 내일 ping을하고 싶다면 여기에서 나와 함께 ping하길 원한다면 나는 온라인에서 너를 만날 수 있는지를 볼 수있다. 나는 미국 중부 표준시 (그리니치 표준시 - 6 그래?). Lemme, 내가 할 수있는 곳에서 디버깅하는 데 도움이되어 기쁩니다. – jcolebrand

관련 문제