Click here to Skip to main content
15,889,767 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when taking gridview in accordion content template tag, gridview1 not showing in the code behind page, why? how can i solve this, pls help.

code is:
ASP.NET
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <ajaxToolkit:Accordion ID="acc1"  runat="server" Width="100%" SuppressHeaderPostbacks="False" ContentCssClass="AccordionContentCss" CssClass="AccordionCss" HeaderCssClass="AccordionHeaderCss" HeaderSelectedCssClass="AccordionHeaderSelectedCss">
        <HeaderTemplate>
            <asp:Label ID="lblHeaderId" runat="server" Text="pel"></asp:Label>
        </HeaderTemplate>
        <ContentTemplate>
            <asp:GridView ID="GridView1" runat="server" DataKeyNames="PersonalityId">
                <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" SortExpression="Name"></asp:BoundField>
                <asp:TemplateField HeaderText="Rating" SortExpression="avg" ItemStyle-CssClass="">
                                        <ItemTemplate>
                                            <ajaxToolkit:Rating CurrentRating='<%# String.IsNullOrEmpty(Eval("avg").ToString())?0:Convert.ToDecimal(Eval("avg")) %>' ID="ratingPersonality"  runat="server" EmptyStarCssClass="ratingEmpty" FilledStarCssClass="ratingFilled" WaitingStarCssClass="ratingSaved" StarCssClass="ratingEmpty" AutoPostBack="True" ></ajaxToolkit:Rating>
                                            <headerstyle font-size="9pt" horizontalalign="Center" />
                                            <itemstyle horizontalalign="Left" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
            </asp:GridView>
        </ContentTemplate>
    </ajaxToolkit:Accordion>

</asp:Content>


What I have tried:

gridview1 not showing in aspx.cs page
Posted

1 solution

Because gridview is inside accordion you cannot access the gridview directly.

What you have to do is access the accordion control and in the controls collections of accordion control you can get the gridview from the collection by using find method
 
Share this answer
 
Comments
[no name] 7-Feb-16 6:55am    
yes sir, u r correct. but how to use find method, pls help details
i want to know, find personid from gridview rowindex and persionid insert with rating value into rate table, how
John C Rayan 7-Feb-16 14:45pm    
Example code

GridView GV = AccordionPane1.FindControl("GridView1") as GridView;

GridViewRow selectedRow = GV.Rows[index];


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900