[RESOLVED] Accordion with Master Detail
I have an accordion AJax Toolkit control which at header level displays a list of categories from datatable1 (a distinct list of categories) , and in the content section I want to display the details (possibly in a grid) from datatable2 (a list of all products and detail including category).
There are plenty of tutorials on how to achieve this.
However the tricky part is that I don't want to re-query the database on opening each header. I would rather the data is pre-filled for each detail section based on the category and just gets displayed.
What would be the best approach to this?
Re: Accordion with Master Detail
Im thinking along these lines at the moment but it cant find the hidden field in the header
Quote:
protected void Accordion1_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
{
if (e.AccordionItem.ItemType == AjaxControlToolkit.AccordionItemType.Content)
{
GridView detailgrd = (GridView)e.AccordionItem.FindControl("gvwDelegates");
DataTable table = ds.Tables["Courses1"];
string expression;
HiddenField hidCusType = (HiddenField)e.AccordionItem.FindControl("hidCusType");
expression = "EventNumber=" + hidCusType.Value;
DataRow[] foundRows;
foundRows = table.Select(expression);
detailgrd.DataSource = foundRows;
// Use the Select method to find all rows matching the filter.
}
}
Re: Accordion with Master Detail
As this seems to be .Net based, thread moved from the 'ASP, VB Script' forum to the 'ASP.Net' forum
Re: Accordion with Master Detail
Haven't done runtime accordion binding so a few suggestions.
You can use page load and inside a not page.ispostback bring the desired data, then fill the accordion with it.
You can use a web service and bind the data to the accordion with jquery. You must know the ajax equivalents for the accordion binding here, if i am not mistake, so it may be a little hard.
What you do, but, If the hidden field you seek is just a number to index the desired data then you can put that in session and get it from there, since you are querying on the server side anyhow.
Re: Accordion with Master Detail
Ok I originally had the hidden field in the header, moving it into the content seemed to fix the issue.
Quote:
<asp:Accordion ID="Accordion1" runat="server" SelectedIndex="0"
AutoSize="None"
FadeTransitions="true"
TransitionDuration="100"
SuppressHeaderPostbacks = "true"
OnItemDataBound="Accordion1_ItemDataBound"
CssClass="accordion"
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent"
Height="100%"
>
<HeaderTemplate>
<table class="delegatestbl"><tr><td width="150px;"><%#DataBinder.Eval(Container.DataItem, "CourseCode")%> </td><td width="350px;"> <%#DataBinder.Eval(Container.DataItem, "CourseTitle")%></td><td width="200px"> <%#DataBinder.Eval(Container.DataItem, "MainRoom")%></td><td width="150px"> <%#DataBinder.Eval(Container.DataItem, "Trainer")%></td></tr></table>
</HeaderTemplate>
<ContentTemplate> <asp:HiddenField runat="server" id="hidCusType" value='<%#DataBinder.Eval(Container.DataItem, "EventNumber")%>' />
<asp:GridView ID="gvwDelegates" runat="server"
DataKeyNames="EventNumber" AutoGenerateColumns="false" CssClass="dgrid">
<Columns>
<asp:BoundField HeaderText="Delegate Name" DataField="DelegateName" />
<asp:BoundField HeaderText="Organisation" DataField="Cust_Name" />
<asp:BoundField HeaderText="Booking No." DataField="Booking_BookingNumber" />
</Columns>
<EmptyDataTemplate>No delegates found.</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
</asp:Accordion>
</div></ContentTemplate>
</asp:UpdatePanel>
</div>