I really hope someone can help me with this... I need this for a client project asap. My goal is to create an Accordion using data from a database.
I've set up a Repeater that generates each AccordionPane for my Atlas Accordion. Within the Repeater's ItemTemplate, data-binding works just fine. However, it stops working inside the AccordionPane definition.
Here's some code that illustrates the problem. I've placed comments inline to show the problem areas.
(sample.aspx):<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sample.aspx.cs" Inherits="sample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<atlas:ScriptManager id="MasterScriptManager" EnablePartialRendering="true" runat="Server" EnableScriptComponents="True" EnableScriptGlobalization="false">
</atlas:ScriptManager>
</head>
<body>
<form id="form1" runat="server">
<div style="width: 50%;">
<atlasToolkit:Accordion ID="myAccordion" runat="server" SelectedIndex="0" FadeTransitions="true" FramesPerSecond="40" TransitionDuration="250" AutoSize="None">
<asp:Repeater ID="myRepeater" runat="server">
<ItemTemplate>
<%-- PUTTING THIS LABEL HERE BINDS PROPERLY
<asp:Label text='<%# DataBinder.Eval(Container.DataItem, "firstName")%>' runat="server"></asp:Label>
<br />
--%>
<atlasToolkit:AccordionPane runat="server">
<Header>
<div style="background-color: #ccc; border: 1px solid black">
First Name:
<%-- UNCOMMENTING THIS LABEL CAUSES ERROR --%>
<asp:Label Text='<%--# DataBinder.Eval(Container.DataItem, "firstName")--%>' runat="server"></asp:Label>
</div>
</Header>
<Content>
<div style="background-color: #00cccc;">
The Accordion is a web control that allows you to provide multiple panes and display
them one at a time.<br /><br />
</div>
</Content>
</atlasToolkit:AccordionPane>
</ItemTemplate>
</asp:Repeater>
</atlasToolkit:Accordion>
</div>
</form>
</body>
</html>
And the code-behind which just binds some sample data to the Repeater (sample.aspx.cs): using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class sample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet dSet = new DataSet();
DataTable dTable = new DataTable("People");
DataRow dRow;
dTable.Columns.Add("firstName", Type.GetType("System.String"));
dTable.Columns.Add("lastName", Type.GetType("System.String"));
dRow = dTable.NewRow();
dRow["firstName"] = "John";
dRow["lastName"] = "Doe";
dTable.Rows.Add(dRow);
dRow = dTable.NewRow();
dRow["firstName"] = "Bob";
dRow["lastName"] = "Smith";
dTable.Rows.Add(dRow);
dSet.Tables.Add(dTable);
myRepeater.DataSource = dSet.Tables["People"];
myRepeater.DataBind();
}
}
As I said, my goal is to create an Accordion where each AccordionPane's Header and Content areas contain various controls that display database info. For example, it's important that I can place a LinkButton in each Header who's ID (or CommandArgument) is set from a field in the database. The LinkButtons will trigger a call to update a UpdatePanel as well as some other javascript code.
Thanks,
-mark