I could not connect to a datasource object via Accordion control

Last post 09-05-2007 12:01 PM by m_imran_mirza. 8 replies.

Sort Posts:

  • I could not connect to a datasource object via Accordion control

    10-04-2006, 4:15 AM
    • Loading...
    • ugum
    • Joined on 07-20-2005, 2:17 PM
    • Istanbul, Turkey
    • Posts 6

    I am using Atlas Control Toolkit and I try to connect my Accordion control to a ObjectDataSource control. I read Atlas Toolkit user manual. It says we can use DataSource and DataSourceID properties for connect to datasource but I could not :(

    My codes is below:

    <atlasToolkit:Accordion BackColor="Gray" ID="acc_1" runat="server" HeaderCssClass="baslik"
    ContentCssClass="icerik" AutoSize="Limit" DataSourceID="ObjectDataSource1" DataSource="ObjectDataSource1.DataBind()">

    I also tried to declare DataSource="ObjectDataSource1"
    and also in c# file,
    acc_1.DataSource = ObjectDataSource1;
    acc_1.DataBind();

    When I run my project, I get "The 'DataSource' property cannot be set declaratively" error. I searched this error but I could not find any related topics.

    How can I do?

    http://umutluoglu.blogspot.com
  • Re: I could not connect to a datasource object via Accordion control

    10-04-2006, 8:22 AM
    • Loading...
    • ugum
    • Joined on 07-20-2005, 2:17 PM
    • Istanbul, Turkey
    • Posts 6

    I solved the problem. I used typed dataset and with help of a for loop, I can bind data on accordion panes. On Page_Load event, I use these codes: 

    DataSet1TableAdapters.KullanicilarTableAdapter tbl_adp = new DataSet1TableAdapters.KullanicilarTableAdapter();
    DataTable dt1 = new DataTable();
    dt1 = tbl_adp.Getir();

     for
    (int i = 0; i < (dt1.Rows.Count); i++)
     {
       AccordionPane pane1 = new AccordionPane();
       pane1.HeaderContainer.Controls.Add(
    new LiteralControl(dt1.Rows[i].ItemArray[0].ToString()));
       pane1.ContentContainer.Controls.Add(
    new LiteralControl(dt1.Rows[i].ItemArray[1].ToString()));
       acc_1.Controls.Add(pane1);
     }

    acc_1 is my Accordion control's ID.

    http://umutluoglu.blogspot.com
  • Re: I could not connect to a datasource object via Accordion control

    10-05-2006, 9:39 PM
    Hi ugum,

    You don't need to set the DataSource property - just set the DataSourceID in your markup and it should work.  For example of databinding an Accordion, check out the Accordion.aspx file in the ToolkitTests project.

    Thanks,
    Ted
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: I could not connect to a datasource object via Accordion control

    10-18-2006, 6:52 AM
    • Loading...
    • shj0633
    • Joined on 07-05-2006, 5:30 AM
    • Posts 1
    Hi,Ted !  Why MyAccordion don't have "DataSourceID"  attribute? 
    .aspx Page:
    "Accordion1" runat="server" DataSourceID="ObjectDataSource1"  >
    
    
    C#:
    Accordion1.DataSource = this.SqlDataSource1;
    Accordion1.DataBind();
    
    
    Error:
    'AtlasControlToolkit.Accordion' does not contain a definition for 'DataSource'	C:\Inetpub\wwwroot\AtlasWebSite1\Test1017\Test16.aspx.cs		20	http://localhost/AtlasWebSite1/
    
    
     I hope you give me some advice !  Many Thanks !
  • Re: I could not connect to a datasource object via Accordion control

    10-25-2006, 9:14 PM
    Hi shj0633,

    I'm not quire sure what you're asking, but you should be able to figure out by looking at the the AjaxControlToolkit\ToolkitTests\Accordion.aspx file which has examples of databound accordions.

    Thanks,
    Ted
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: I could not connect to a datasource object via Accordion control

    11-02-2006, 2:36 PM
    • Loading...
    • ldadams
    • Joined on 09-08-2004, 3:34 PM
    • Posts 37

    Hi, I just downloaded the latest toolkit and I do not see an examples of databound accordions.  Any suggestions?

    Thanks
    Luke

  • Re: I could not connect to a datasource object via Accordion control

    11-02-2006, 2:43 PM
    • Loading...
    • ldadams
    • Joined on 09-08-2004, 3:34 PM
    • Posts 37
    Figured this out.  Was alot easier then I was tring to make it.
  • Re: I could not connect to a datasource object via Accordion control

    12-08-2006, 10:28 AM
    • Loading...
    • Konstantin
    • Joined on 10-09-2006, 2:47 PM
    • Posts 6
    Could You show exemple. My code didn`t work:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    DataSet ds1 = new DataSet();
    SqlConnection cn1 = new SqlConnection(ConfigurationSettings.AppSettings["cn"]);
    string CNString1 = "SELECT VacName,VacDescription FROM table";
    SqlCommand myCommand1 = new SqlCommand(CNString1, cn1);
    SqlDataAdapter da1 = new SqlDataAdapter(myCommand1);
    da1.Fill(ds1, "table");
    MyAccordion.DataSource = ds1;
    MyAccordion.DataBind();
    }
    }


    <ajaxToolkit:Accordion ID="MyAccordion" runat="server" SelectedIndex="0" >
    <HeaderTemplate >
    < %= Eval("VacName")% >
    < /HeaderTemplate >
    < ContentTemplate >
    < %= Eval("VacDescription")% >
    < /ContentTemplate >
    </ajaxToolkit:Accordion >

    What am I doing wrong?
  • Re: I could not connect to a datasource object via Accordion control

    09-05-2007, 12:01 PM

    I had same problem, and the simple trick is that you forgot to add Panes tag before HeaderTemplate tag.

     

    Here is the working code, enjoy

       

    <ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1" />

        <ajaxToolkit:Accordion ID="MyAccordion" runat="Server"
         SelectedIndex="0" HeaderCssClass="accordionHeader"
         ContentCssClass="accordionContent" AutoSize="None"
         FadeTransitions="true" TransitionDuration="250"
         FramesPerSecond="40" DataSourceID="SqlDataSource1">

            

            <Panes>

            </Panes>

            

            <HeaderTemplate>            <a href="" onclick="return false;"><%# Eval("Title") %></a>        </HeaderTemplate>

           

            <ContentTemplate>            <%# Eval("Body") %>

            </ContentTemplate>

         </ajaxToolkit:Accordion>   

        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
         ConnectionString="<%$ ConnectionStrings:aaaConnectionString %>"
         
    SelectCommand="SELECT [Title], [Body] FROM [Table1]"></asp:SqlDataSource>

     

     

    Regards,
    Imran Baig

Page 1 of 1 (9 items)
Microsoft Communities
Page view counter