using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
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;
using System.Data.SqlClient;

public partial class index : System.Web.UI.Page
{
protected Repeater childRepeater;//parentRepeater;
public index()
{
Page.Init += new EventHandler(Page_Init);
}
public void Page_Load(object sender, EventArgs e)
{

//Create the connection and DataAdapter for the Authors table.//创建连接,DataAdapter作者表.
string s = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\xlgameguide.mdf;Integrated Security=True;Connect Timeout=30";
SqlConnection con = new SqlConnection(s);
SqlDataAdapter cmd1 = new SqlDataAdapter("select * from gamestyle", con);
//Create and fill the DataSet.//创建和填充数据集。
DataSet ds = new DataSet();
cmd1.Fill(ds, "fenlei");
//Create a second DataAdapter for the Titles table.//创建第二个DataAdapter的标题表。
SqlDataAdapter cmd2 = new SqlDataAdapter("select * from newswords", con);
cmd2.Fill(ds, "wenzhang");
//Create the relation bewtween the Authors and Titles tables.//创建bewtween作者和标题的关系表。
ds.Relations.Add("myrelation",
ds.Tables["fenlei"].Columns["gamestyleid"],
ds.Tables["wenzhang"].Columns["gamestyleid"]);
//Bind the Authors table to the parent Repeater control, and call DataBind.//作者表绑定到父中继器控制和调用DataBind。
parentRepeater.DataSource = ds.Tables["fenlei"];
Page.DataBind();
//Close the connection.//关闭连接。
con.Close();
cmd1.Dispose();
cmd2.Dispose();

//这段是在页面绑定的格式
//<asp:repeater id="parentRepeater" runat="server">
// <itemtemplate>
// <b><%# DataBinder.Eval(Container.DataItem,"gamestyle") %></b><br>
// <!-- start child repeater -->
// <asp:repeater id="childRepeater" datasource='<%# ((System.Data.DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>' runat="server">
// <itemtemplate>
// <%# DataBinder.Eval(Container.DataItem, "[\"newsname\"]")%><br>
// </itemtemplate>
// </asp:repeater>
// <!-- end child repeater -->
// </itemtemplate>
//</asp:repeater>

}
//两个无返回值的必须的方法
private void Page_Init(object sender, EventArgs e)
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}

}

asp.net:repeater嵌套(常用于新闻等在首页归类显示)的更多相关文章

  1. ASP.NET Repeater嵌套Repeater实现菜单加载

    在KS系统中要实现从数据库中读取界面权限文件实现菜单.界面的动态加载. 效果图: ASP.NET界面代码 <div id="menu-container"> <a ...

  2. [ASP.NET]asp.net Repeater控件的使用方法

    asp.net Repeater控件的使用方法 -- : 4770人阅读 评论() 收藏 举报 asp.netserveraspdatasetdeletexhtml 今天学习了,Repeater控件 ...

  3. ASP.NET中的常用快捷键

    想查找ASP.NET中的属性快捷键,忘记了,搜了一下,找到了ASP.NET中的常用快捷键. 大神文章:http://www.cnblogs.com/xiacao/archive/2012/06/12/ ...

  4. ASP.NET repeater添加序号列的方法

    ASP.NET repeater添加序号列的方法 1.<itemtemplate> <tr><td> <%# Container.ItemIndex + 1% ...

  5. 使用Word API打开Word文档 ASP.NET编程中常用到的27个函数集

    使用Word API(非Openxml)打开Word文档简单示例(必须安装Word) 首先需要引入参照Microsoft.Office.Interop.Word 代码示例如下: public void ...

  6. discuz 修改亮剑积分商城2.91模板(在常用设置中添加商场首页排序方式的背景颜色)

    在应用 -> 积分商城 -> 常用设置 中添加 商场首页排序方式 的背景颜色修改功能 步骤: 1.找到并打开此页面对应的模板source\plugin\aljsc\template\set ...

  7. phpstorm常用快捷键有哪些(图解归类)

    phpstorm常用快捷键有哪些(图解归类) 一.总结 一句话总结: 10.方法参数提示,显示默认参数   解答:--------CTRL+P 13.显示类层级关系图,继承/实现关系   解答:--- ...

  8. ASP.NET- 查找Repeater控件中嵌套的控件

    如何在Repeater的HeaderTemplate和FooterTemplate模板中寻找控件?在Repeater的ItemTemplate模板中的控件,我们可以用Items属性来遍历行并用Find ...

  9. asp.net repeater控件操作

    Repeater控件和DataList控件,可以用来一次显示一组数据项.比如,可以用它们显示一个数据表中的所有行. Repeater控件完全由模板驱动,提供了最大的灵活性,可以任意设置它的输出格式. ...

随机推荐

  1. 求正整数n所有可能的和式的组合(如;4=1+1+1+1、1+1+2、1+3、2+1+1、2+2

    作者:张小二 nyoj90 ,可以使用递归的方式直接计算个数,也可以通过把满足的个数求出来计数,因为在juLy博客上看到整数划分,所以重写了这个代码,就是列出所m的可能性,提交后正确.acmer的入门 ...

  2. AABB碰撞盒

    矩形边界框(转) 另一种常见的用来界定物体的几何图元是矩形边界框,矩形边界框可以是与轴对齐的或是任意方向的.轴对齐矩形边界框有一个限制,就是它的边必须垂直于坐标轴.缩写AABB常用来表示axially ...

  3. [九度OJ]1137.浮点数加法

    原题链接:http://ac.jobdu.com/problem.php?pid=1137 题目描述: 求2个浮点数相加的和题目中输入输出中出现浮点数都有如下的形式:P1P2...Pi.Q1Q2... ...

  4. bzoj 1879 [Sdoi2009]Bill的挑战(状压DP)

    Description  Input 本题包含多组数据. 第一行:一个整数T,表示数据的个数. 对于每组数据: 第一行:两个整数,N和K(含义如题目表述). 接下来N行:每行一个字符串. Output ...

  5. Codeforces Round #343 (Div. 2) B. Far Relative’s Problem

    题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面. 思路:ans=max(2*min(一天中有多少个人能出面)) #include<iostream> #include< ...

  6. PC-飞起来!我的Windows XP——五步快速优化Windows XP

    虽然Microsoft的 Vista已经发售了快一年,但国内大部分系统用户仍使用着目前堪称完美的Windows XP.与以往的Windows操作系统一样,新安装的Windows XP可能还不在最佳状态 ...

  7. 工作7年,从《一个苏州IT人的5年挨踢经历》系列开始,博客1年半,纯纪念

    真正涉足CSDN,还是从<一个苏州IT人的5年挨踢经历>系列的发帖开始,当时大家比较捧场,遂把帖子内容整理,其后创建CSDN博客并发表于其上.有了这个开端,后续就习惯性的开始在CSDN写技 ...

  8. 升级web项目步骤

    1.备份数据库(数据库服务器cmd执行,exp pra/pra@ORCL file=c:\name.dmp)2.删除原有表,导入新的备份文件(数据库服务器cmd执行,imp pra/pra@ORCL ...

  9. Activity 的启动模式

    好久没用过那几种activity的启动模式了,如今看到singletop竟然傻了眼,完全忘记了这几种启动模式的区别!隧将两年前的总结翻出来,通读一遍那晦涩难懂的记录,又理解了一遍,在以前记录的基础上, ...

  10. C++中的类访问控制

    C++中 public,protected, private 访问标号小结 第一:private, public, protected 访问标号的访问范围. private:只能由1.该类中的函数.2 ...