Accordion 嵌套取值 100分

ziyouren521125 2009-01-10 05:45:02
想用Accordion 实现菜单功能。
我这大类跟小类都想从数据库读取。
大类一
小类1
大类二
小类2
小类21
小类22
大类三
小类3
小类31
小类32

像上面的那样。
为什么我绑定了以后数据却没有显示出来。
有源码的考一份也可以


//我的代码,不过我的外面还有一层UpdatePanel

<asp:DataList id="DataList3" runat="server" DataSourceID="SqlDataSource1" Height="33px" Width="755px" DataKeyField="CourseId">
<ItemTemplate>
<cc1:Accordion ID="Accordion1" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent" SuppressHeaderPostbacks="true" RequireOpenedPane="false" runat="server">
<Panes>
<cc1:AccordionPane ID="AccordionPane1" runat="server" >
<Header><asp:Label id="Label7" runat="server" Text='<%# Bind("CourseName") %>'></asp:Label></Header>
<Content>
<asp:DataList ID="DataList" runat="server" DataSourceID="SqlDataSource2" DataKeyField="">
<ItemTemplate>
<asp:Label id="Label6" runat="server" Text='<%# Bind("LWContent") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
</Content>
</cc1:AccordionPane>
</Panes>
</cc1:Accordion>
</ItemTemplate>
</asp:DataList>

<asp:SqlDataSource id="SqlDataSource1" runat="server" SelectCommand="SELECT [CourseId], [CourseName] FROM [CourseLWInfo] WHERE ([Tid] = @Tid)" ConnectionString="<%$ ConnectionStrings:LoreMartConnectionString %>">
<SelectParameters>
<asp:SessionParameter Name="Tid" SessionField="TeacherId" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:LoreMartConnectionString %>"
SelectCommand="SELECT [LWContent], [LWTime], [LWState], [RevertContent], [RevertTime] FROM [CourseLWInfo] WHERE (([LWState] <> @LWState) AND ([CourseId] = @CourseId))">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="LWState" Type="Int32" />
<asp:ControlParameter ControlID="DataList1" Name="CourseId" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

...全文
212 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zcxverygood123456 2011-12-17
  • 打赏
  • 举报
回复
哈哈,研究成功了。
erytbc 2009-01-19
  • 打赏
  • 举报
回复
帮DING
nick207 2009-01-18
  • 打赏
  • 举报
回复
你先在页面的后置代码设置断点 看看从数据层得到的数据
到底是不是你想要的
niitnanfeng 2009-01-18
  • 打赏
  • 举报
回复
gonghuaqiao 2009-01-18
  • 打赏
  • 举报
回复
前台
<cc1:Accordion ID="Accordion1" runat="server" HeaderCssClass="headerBg" ContentCssClass="content">
<Panes>
</Panes>
</cc1:Accordion>

后台
if (!IsPostBack)
{
string id =Session["userid"].ToString();
//string id = "CZY01";
DataSet ds = BLL.Sys_permitManager.GetLeft(id);
DataTable dt = ds.Tables[0];
DataView dv = ds.Tables[1].DefaultView;

foreach (DataRow row in dt.Rows)
{
AccordionPane ap = new AccordionPane();
Label header = new Label();
header.Text = row["title"].ToString();
ap.HeaderContainer.Controls.Add(header);
int i = Convert.ToInt32(row["id"].ToString());
dv.RowFilter = "parentid=" + i.ToString();
foreach (DataRow row1 in dv.ToTable().Rows)
{
Label conten = new Label();
conten.Text = "<a target='" + row1["target"].ToString() + "' href='" + row1["url"].ToString() + "'>" + row1["title"] + "</a><br/><br/>";
ap.ContentContainer.Controls.Add(conten);
}
Accordion1.Panes.Add(ap);
}
// Accordion1.SelectedIndex = 0;

}
我以前项目的一段例子

Mc_Grady_ 2009-01-15
  • 打赏
  • 举报
回复
看不懂. 帮你顶上去...
ziyouren521125 2009-01-13
  • 打赏
  • 举报
回复

怎么没有人回答啊。加起来150分啊~~~~~~~~~~~
就没有ajax高手吗?
ziyouren521125 2009-01-13
  • 打赏
  • 举报
回复

怎么没有人回答啊。加起来150分啊~~~~~~~~~~~
就没有ajax高手吗?
ziyouren521125 2009-01-12
  • 打赏
  • 举报
回复
其实就是想实现菜单的样子
a5213062 2009-01-10
  • 打赏
  • 举报
回复
完全不懂````
Even713 2009-01-10
  • 打赏
  • 举报
回复
帮顶~

52,782

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧