无为清净楼资源网 Design By www.qnjia.com
1.A,运行效果图
1.B,源代码(主要代码摘要)
/App_Code/DBConnection.cs
/App_Code/CategoryInfo.cs
复制代码 代码如下:
using System.Collections.Generic;
public class CategoryInfo
{
int categoryid;
string categoryname;
string categorydesc;
IList<ArticleInfo> articles;
/// <summary>
/// 1,子嵌套数据
/// </summary>
public IList<ArticleInfo> Articles
{
get { return articles; }
set { articles = value; }
}
public int Categoryid
{
get { return categoryid; }
set { categoryid = value; }
}
public string Categoryname
{
get { return categoryname; }
set { categoryname = value; }
}
public string Categorydesc
{
get { return categorydesc; }
set { categorydesc = value; }
}
public CategoryInfo()
{
}
public CategoryInfo(int categoryid, string categoryname, string categorydesc,IList<ArticleInfo> articles)
{
this.categoryid = categoryid;
this.categoryname = categoryname;
this.categorydesc = categorydesc;
this.articles = articles;
}
}
/App_Code/ArticleInfo.cs
/App_Code/CategoryOper.cs
复制代码 代码如下:
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
public class CategoryOper
{
public static IList<CategoryInfo> SelectAll()
{
IList<CategoryInfo> allcate = new List<CategoryInfo>();
string sql = "select category.categoryid,categoryname,categorydesc,id,title,author from category inner join article on category.categoryid=article.categoryid order by category.categoryid";
SqlConnection con = new DBConnection().Con;
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText = sql;
com.CommandType = CommandType.Text;
con.Open();
SqlDataReader sdr = com.ExecuteReader();
int tempcategoryid=0;
CategoryInfo cate=null;
while (sdr.Read())
{
int categoryid=sdr.GetInt32(0);
//如果类别改变则创建一个新的 cate 对象
if(categoryid!=tempcategoryid)
{
cate = new CategoryInfo(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), new List<ArticleInfo>());
allcate.Add(cate);
tempcategoryid = categoryid; //把新类别编号付给标识
}
ArticleInfo art = new ArticleInfo(sdr.GetInt32(3), sdr.GetString(4), sdr.GetString(5));
cate.Articles.Add(art);
}
con.Close();
return allcate;
}
public CategoryOper()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
/App_Code/ArticleOper.cs
,6
/Default.aspx
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align:center">
<asp:Repeater ID="RepCate" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<td>分类编号</td>
<td>分类名称</td>
<td>分类描述</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("categoryid") %></td>
<td><%#Eval("categoryname") %></td>
<td><%#Eval("categorydesc") %></td>
</tr>
<tr>
<td>本类新闻</td>
<td colspan="2">
<asp:Repeater ID="RepArticle" runat="server" DataSource='<%#Eval("articles") %>' >
<HeaderTemplate>
<table border="1" style="background-color:#00FF00;">
<tr>
<td>新闻编号</td>
<td>新闻标题</td>
<td>新闻作者</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("id") %></td>
<td>
<asp:HyperLink ID="Hl1" runat="server" Text='<%#Eval("title") %>' NavigateUrl='<%#string.Format("ShowArticle.aspx?id={0}",Eval("id") ) %>' ></asp:HyperLink>
</td>
<td><%#Eval("author") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
/Default.aspx.cs
复制代码 代码如下:
using System;
public partial class _Default : System.Web.UI.Page
{
private void BindCategory()
{
RepCate.DataSource = CategoryOper.SelectAll();
RepCate.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCategory();
}
}
}
/web.config
1.C,资源下载
1.B,源代码(主要代码摘要)
/App_Code/DBConnection.cs
/App_Code/CategoryInfo.cs
复制代码 代码如下:
using System.Collections.Generic;
public class CategoryInfo
{
int categoryid;
string categoryname;
string categorydesc;
IList<ArticleInfo> articles;
/// <summary>
/// 1,子嵌套数据
/// </summary>
public IList<ArticleInfo> Articles
{
get { return articles; }
set { articles = value; }
}
public int Categoryid
{
get { return categoryid; }
set { categoryid = value; }
}
public string Categoryname
{
get { return categoryname; }
set { categoryname = value; }
}
public string Categorydesc
{
get { return categorydesc; }
set { categorydesc = value; }
}
public CategoryInfo()
{
}
public CategoryInfo(int categoryid, string categoryname, string categorydesc,IList<ArticleInfo> articles)
{
this.categoryid = categoryid;
this.categoryname = categoryname;
this.categorydesc = categorydesc;
this.articles = articles;
}
}
/App_Code/ArticleInfo.cs
/App_Code/CategoryOper.cs
复制代码 代码如下:
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
public class CategoryOper
{
public static IList<CategoryInfo> SelectAll()
{
IList<CategoryInfo> allcate = new List<CategoryInfo>();
string sql = "select category.categoryid,categoryname,categorydesc,id,title,author from category inner join article on category.categoryid=article.categoryid order by category.categoryid";
SqlConnection con = new DBConnection().Con;
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText = sql;
com.CommandType = CommandType.Text;
con.Open();
SqlDataReader sdr = com.ExecuteReader();
int tempcategoryid=0;
CategoryInfo cate=null;
while (sdr.Read())
{
int categoryid=sdr.GetInt32(0);
//如果类别改变则创建一个新的 cate 对象
if(categoryid!=tempcategoryid)
{
cate = new CategoryInfo(sdr.GetInt32(0), sdr.GetString(1), sdr.GetString(2), new List<ArticleInfo>());
allcate.Add(cate);
tempcategoryid = categoryid; //把新类别编号付给标识
}
ArticleInfo art = new ArticleInfo(sdr.GetInt32(3), sdr.GetString(4), sdr.GetString(5));
cate.Articles.Add(art);
}
con.Close();
return allcate;
}
public CategoryOper()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
/App_Code/ArticleOper.cs
,6
/Default.aspx
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align:center">
<asp:Repeater ID="RepCate" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<td>分类编号</td>
<td>分类名称</td>
<td>分类描述</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("categoryid") %></td>
<td><%#Eval("categoryname") %></td>
<td><%#Eval("categorydesc") %></td>
</tr>
<tr>
<td>本类新闻</td>
<td colspan="2">
<asp:Repeater ID="RepArticle" runat="server" DataSource='<%#Eval("articles") %>' >
<HeaderTemplate>
<table border="1" style="background-color:#00FF00;">
<tr>
<td>新闻编号</td>
<td>新闻标题</td>
<td>新闻作者</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("id") %></td>
<td>
<asp:HyperLink ID="Hl1" runat="server" Text='<%#Eval("title") %>' NavigateUrl='<%#string.Format("ShowArticle.aspx?id={0}",Eval("id") ) %>' ></asp:HyperLink>
</td>
<td><%#Eval("author") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
/Default.aspx.cs
复制代码 代码如下:
using System;
public partial class _Default : System.Web.UI.Page
{
private void BindCategory()
{
RepCate.DataSource = CategoryOper.SelectAll();
RepCate.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCategory();
}
}
}
/web.config
1.C,资源下载
标签:
repeater,嵌套
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月16日
2024年11月16日
- 海来阿木《西楼情歌》开盘母带[WAV+CUE][1.1G]
- TheGesualdoSix-QueenofHeartsLamentsandSongsofRegretforQueensTerrestrialandCele
- 王建杰2011-荣华富贵[喜玛拉雅][WAV+CUE]
- 孙悦2024-时光音乐会[金蜂][WAV+CUE]
- 秦宇子.2020-#YUZI【海蝶】【FLAC分轨】
- 苏有朋.1994-这般发生【华纳】【WAV+CUE】
- 小虎队.1990-红蜻蜓【飞碟】【WAV+CUE】
- 雷婷《寂寞烟火HQⅡ》头版限量[低速原抓WAV+CUE][1G]
- 赵传1996《黑暗英雄》台湾首版[WAV+CUE][1G]
- 张敬轩2005《我的梦想我的路》几何娱乐[WAV+CUE][1G]
- 群星《人到四十男儿情(SRS+WIZOR)》[原抓WAV+CUE]
- 马久越《上善若水HQCDII》[低速原抓WAV+CUE]
- 龚玥《女儿情思》6N纯银SQCD【WAV+CUE】
- 张惠妹《你在看我吗》大碟15 金牌大风[WAV+CUE][1G]
- 群星《左耳·听见爱情》星文唱片[WAV+CUE][1G]