它没有显示在TabContainer中

本文关键字:TabContainer 显示 | 更新日期: 2023-09-27 18:01:04

我的代码中有一个ajaxtoolkit:TabContainer。我把网格视图放在里面。但当我运行项目时,它没有显示网格视图。gridview很好,当它不在TabContainer中时会显示数据。

这是我的aspx代码:

            <ajaxToolkit:TabPanel ID="tbAgency" runat="server" HeaderText="Agency"  >
                   <ContentTemplate>
                       <asp:GridView ID="grAgency" runat="server" CellPadding="4" 
                                                                ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
                                                                 Width="901px" style="cursor: pointer;" AllowPaging="True" 
                                                                 AllowSorting="True" PageSize="20">
                                                                <AlternatingRowStyle BackColor="White" />
                                                                <EditRowStyle BackColor="#7C6F57" />
                                                                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                                                <HeaderStyle BackColor="green" Font-Bold="True" ForeColor="White" 
                                                                    Font-Size="Small" HorizontalAlign="Left" />
                                                                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                                                                <RowStyle BackColor="#c9d9c9" Font-Size="Small" />
                                                                <SortedAscendingCellStyle BackColor="#F8FAFA" />
                                                                <SortedAscendingHeaderStyle BackColor="#246B61" />
                                                                <SortedDescendingCellStyle BackColor="#D4DFE1" />
                                                                <SortedDescendingHeaderStyle BackColor="#15524A" />
                                                                <Columns>
                                                                    <asp:BoundField HeaderText="Agency Name" DataField="Name" 
                                                                        ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
                                                                    <HeaderStyle HorizontalAlign="Left" />
                                                                        <ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
                                                                    </asp:BoundField>
                                                                    <asp:BoundField HeaderText="Description" DataField="Description" 
                                                                        ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
                                                                    <HeaderStyle HorizontalAlign="Left" />
                                                                        <ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
                                                                    </asp:BoundField>
                                                                    <asp:BoundField HeaderText="Contact Name" DataField="ContactName" 
                                                                        ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
                                                                    <HeaderStyle HorizontalAlign="Left" />
                                                                        <ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
                                                                    </asp:BoundField>
                                                                    <asp:BoundField HeaderText="Contact Phone" DataField="Phone" 
                                                                        ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
                                                                    <HeaderStyle HorizontalAlign="Left" />
                                                                        <ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
                                                                    </asp:BoundField>
                                                                    </Columns>
                                                                </asp:GridView>
                       <asp:Button ID="btnAddAgency" Text="Add Agency" runat="server" />
                       <asp:TextBox ID="txtAgencySearch" runat="server" />
                       <asp:Button ID="btnSearchAgency" runat="server" Text="Search" />
                    </ContentTemplate>    
           </ajaxToolkit:TabPanel>

这是我的C#代码,当下拉列表发生变化时,它会在网格中显示数据。(但网格只有在选项卡外部时才可见,当我把它放在选项卡内部时,它就会消失

    protected void ddlPartnerList_SelectedIndexChanged(object sender, EventArgs e)
    {
            Aid = Convert.ToInt32(ddlPartnerList.SelectedItem.Value);
            if (Aid != 0)
            {
            Session["Aid"] = Aid;
            TabContainer1.ActiveTabIndex = 0;

            var AgencyList = adminmv.getAgency(Aid);
            grAgency.DataSource = AgencyList;
            grAgency.DataBind();
        }
    }

它没有显示在TabContainer中

将GridView放在TabPanel的ContentTemplate内的UpdatePanel内的ContentTemplate中,并确保页面上有ToolkitScriptManager控件。

<tabPanel>
     <contentTemplate>
          <updatePanel>
               <contentTemplate>
                     <gridview>