Accordion control not visible when databinding

Last post 08-10-2008 6:19 AM by Thyagaraju Govardhan. 16 replies.

Sort Posts:

  • Accordion control not visible when databinding

    08-08-2007, 2:11 PM
    • Loading...
    • Loki
    • Joined on 09-05-2005, 8:14 PM
    • Posts 53

    I can't seem to get the accordion to databind at all.  If I put in the static panels, it appears, but when I databind, nothing shows up.  My ultimate goal is to have a repeater of accordions.  I am doing an FAQ page, and I have groups for the FAQ's (the repeater) and then the questions for each group (the accordian).  I am dropping an ID I need into an invisible label and pulling it out on databind of the repeater to pull in the data I need for the accordion.  However, it isn't appearing.

     So, for a test I put in an accordion with static defined panels and all works fine.  I even tried databinding to an accordion outside the repeater, and no luck there either.

    Here is my aspx page.  I am using Master Pages.  In the back, all I am doing is a databind of a System.Data.DataTable to accordianFAQTest.  Ignore the repeater for now.

     

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderPage" Runat="Server">
    <asp:ScriptManager ID="scriptManager" runat="server"  />
    <asp:Repeater ID="repeaterFAQ" runat="server" OnItemDataBound="repeaterFAQ_ItemDataBound">
    <ItemTemplate>
    <h2><%# DataBinder.Eval(Container.DataItem, "DisplayText") %></h2>
    <asp:Label ID="labelId" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem, "FAQGroupId") %>' />
    <ajaxToolkit:Accordion ID="accordianFAQ" SuppressHeaderPostbacks="true" runat="server" >
    <HeaderTemplate>Test<%# Eval("QuestionText") %></HeaderTemplate>
    <ContentTemplate>Test<%# Eval("AnswerText") %></ContentTemplate>
    </ajaxToolkit:Accordion>
    <asp:Panel ID="panelNoHelpTopics" runat="server" Visible="false">
    There are no help topics available for this group.
    </asp:Panel>
    <br />
    </ItemTemplate>
    </asp:Repeater>
    
    <ajaxToolkit:Accordion ID="accordianFAQTest" SuppressHeaderPostbacks="true" runat="server" >
    <HeaderTemplate><%# DataBinder.Eval(Container.DataItem, "QuestionText") %></HeaderTemplate>
    <ContentTemplate><%# DataBinder.Eval(Container.DataItem, "AnswerText")%></ContentTemplate>
    </ajaxToolkit:Accordion>
    
    <asp:Panel ID="panelNoHelp" runat="server" Visible="false">
    There are no help topics available.
    </asp:Panel>
    </asp:Content>

     Does anyone know why the accordion isn't showing when databinding?

     

    Thanks

     

    Loki

    Loki

    Broken Bokken Productions
  • Re: Accordion control not visible when databinding

    08-08-2007, 3:18 PM
    • Loading...
    • ysw
    • Joined on 06-15-2007, 4:32 PM
    • Ukraine
    • Posts 514

    Hi,

    Do you assign DataSource to your Accordion controls?

    -yuriy

  • Re: Accordion control not visible when databinding

    08-08-2007, 3:23 PM
    • Loading...
    • Loki
    • Joined on 09-05-2005, 8:14 PM
    • Posts 53

    Yes.  the databinding is done in the page load and looks like this

     

     

    DataTable questions = MyAPI.SQL.GetFAQs(1);
    
    accordianFAQTest.DataSource = questions;
    accordianFAQTest.DataBind();
     
    Loki

    Broken Bokken Productions
  • Re: Accordion control not visible when databinding

    08-08-2007, 4:09 PM
    • Loading...
    • ysw
    • Joined on 06-15-2007, 4:32 PM
    • Ukraine
    • Posts 514

    Hi,

    if you databind a GridView with autocolumns, do you see columns with correct bnames and correct rows there?

    I do not see problems with Accordion control if databound in page_load.

    -yuriy

  • Re: Accordion control not visible when databinding

    08-08-2007, 4:14 PM
    • Loading...
    • Loki
    • Joined on 09-05-2005, 8:14 PM
    • Posts 53

    I debugged the code and the Datatable I am binding has 1 row with the columns I have specified in the accordion, yet is still shows nothing.

    Loki

    Broken Bokken Productions
  • Re: Accordion control not visible when databinding

    08-13-2007, 5:14 AM

    Hi,

    I suggest performing dataBinding in repeater's ItemDataBound event handler.

    Please try it. If it still doesn't work, please post your full source here. It'll be better if you can modify it a little bit to make use of Northwind database.

     

  • Re: Accordion control not visible when databinding

    08-14-2007, 5:20 AM
    Answer

    According to my investigation, the dataSource of the Accordion must implement IEnumerable interface. But DataTable doesn't implement it.

    Please try to use DataReader instead.

    Hope this helps.

     

  • Re: Accordion control not visible when databinding

    08-14-2007, 9:45 AM

    I don't see anything wrong with the way you have it now. I suggest you set a break point and step into the Databind process so you can walk through the code to find the problem. I am sure you can bind a table to an accordion so do a walkthrough debug on DATABIND and it will help you detect the error.

     

     

    Dollarjunkie

    .Net Web/Software Engineer
  • Re: Accordion control not visible when databinding

    08-22-2007, 11:42 AM
    Answer
    • Loading...
    • Loki
    • Joined on 09-05-2005, 8:14 PM
    • Posts 53

    I fixed this by using the collapsiblepanelextender control and manually building my own accordion.

    Loki

    Broken Bokken Productions
  • Re: Accordion control not visible when databinding

    09-12-2007, 6:36 PM
    • Loading...
    • mpaterson
    • Joined on 11-27-2006, 3:24 AM
    • St. Petersburg, Florida
    • Posts 1,097

    Can you let me know how you did that?  I'm having the same issue.

    Thanks

    If everything happens for a reason what is the reason for this error?
  • Re: Accordion control not visible when databinding

    09-25-2007, 4:55 AM
    • Loading...
    • Steffff
    • Joined on 11-27-2006, 3:39 PM
    • Posts 41

    Accordion databinding won't work with DataSet or DataTable.

    You have to use DataView or DataReader.

    Try :

    <ajaxToolkit:Accordion runat="server" DataSource='<%# new System.Data.DataTableReader(myDataTable) %>'>

    or :

    <ajaxToolkit:Accordion runat="server" DataSource='<%# new System.Data.DataTableReader(myDataTable) %>'>

    Filed under: ,
  • Re: Accordion control not visible when databinding

    09-26-2007, 5:18 PM
    • Loading...
    • mpaterson
    • Joined on 11-27-2006, 3:24 AM
    • St. Petersburg, Florida
    • Posts 1,097

    FYI, it will work with a DataTable but you have to use an ObjectDataSource and wrap your DataTable in a Data Class.

    If everything happens for a reason what is the reason for this error?
  • Re: Accordion control not visible when databinding

    01-07-2008, 11:23 AM
    • Loading...
    • arviy
    • Joined on 01-07-2008, 6:15 AM
    • Posts 5

     it doesn'tttttttttttt work!!!

    can't somebody who has done it put an example which work!

    this way it really is ajax for html.net rather than asp 

  • Re: Accordion control not visible when databinding

    01-07-2008, 8:21 PM
    • Loading...
    • mpaterson
    • Joined on 11-27-2006, 3:24 AM
    • St. Petersburg, Florida
    • Posts 1,097

    Create a Data Class which returns your DataBinding object (ie a dataTable).

    // DataClass
    [DataObjectMethod(DataObjectMethodType.Select, true)]public DataSet Select()

    {

    //Call the class that will connect with your DB.... and return your DataTable
    DataTable myTable = GetMyData();

    }

     

    // Actual Class that gets your data
    private DataTable GetMyData()

    {

     // Your code to get your dataTable here

    return dataTable;

    }

    // Add an OBJECT DataSource to your Accordian
    <asp:ObjectDataSource ID="MyObjectDataSource" runat="server" TypeName="DataAccess" SelectMethod="Select"></asp:ObjectDataSource>

    <cc1:Accordion ID="weekAccordian"

    runat="server"

    FadeTransitions="true"

    FramesPerSecond="40"

    TransitionDuration="40"

    OnItemDataBound="weekAccordian_ItemDataBound"

    DataSourceID="MyObjectDataSource">

    If everything happens for a reason what is the reason for this error?
  • Re: Accordion control not visible when databinding

    07-17-2008, 6:36 AM
     Please use the following:

    <ajaxToolkit:Accordion ID="ajxInxAccrd" runat="server" HeaderCssClass="accordionHeader"
    ContentCssClass="accordionContent" RequireOpenedPane="false" SuppressHeaderPostbacks="false"
    FadeTransitions="true" FramesPerSecond="40" TransitionDuration="250">

    <HeaderTemplate>
    <%#DataBinder.Eval(Container.DataItem, "name")%>
    </HeaderTemplate>
    <ContentTemplate>
    <%#DataBinder.Eval(Container.DataItem, "name")%>
    </ContentTemplate>

    Code for Data binding Accordion:

    DataTable dt = new DataTable();
    DataColumn Col =new DataColumn("name",typeof(string));
    Col.ColumnName = "name";
    dt.Columns.Add(Col);

    DataRow dr;

    dr = dt.NewRow();
    dr["name"] = "This is the value for A";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr["name"] = "This is the value for B";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr["name"] = "This is the value for C";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr["name"] = "This is the value for D";
    dt.Rows.Add(dr);

    ajxInxAccrd.DataSource = new DataTableReader(dt);
    ajxInxAccrd.DataBind();

     Regards,

    Thyagaraju Govardhan

    thyagaraju.g@gmail.com