我想实现 这样的一个效果[分类] 此分类下的相关数据 此分类下的相关数据 此分类下的相关数据 [更多]例子:[下载软件] 脱兔下载 网络蚂蚁 网际快车 [更多]那数据库的表 和 字段 应该怎么设置好?我现在是这样但 总是不能实现上面那个效果数据中 2个表,一个表储存分类
字段有 ID [自动增量] ,分类名称[文本类型]另一个表储存数据
假设有 字段 ID,分类ID,数据
我用asp.net 应该怎么写能 实现上面的效果?
字段有 ID [自动增量] ,分类名称[文本类型]另一个表储存数据
假设有 字段 ID,分类ID,数据
我用asp.net 应该怎么写能 实现上面的效果?
public void BindGrid()
{
DB op = new DB();
SqlConnection cn = op.createConn2;
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select * from news_class",cn);
da.Fill(ds);
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind();
for(int i=0;i<this.DataGrid1.Items.Count;i++)
{
Label l = (Label)this.DataGrid1.Items[i].FindControl("lblBigID");
DataGrid dg = (DataGrid)this.DataGrid1.Items[i].FindControl("DataGrid2");
SqlDataAdapter da2 = new SqlDataAdapter("select * from news where classid="+l.Text,cn);
DataSet ds2 = new DataSet();
da2.Fill(ds2);
dg.DataSource = ds2;
dg.DataBind();
}
}
很多攻能都有,不要自己做。表码,个人觉得应该做两个表,一个类型的。一个内容的。 create table TypeTable
(TypeID int identity(1,1) primary key, TypeName varchar(20)) create table 内容表
(内容ID int primary key,TypeID int foreign key References TypeTable(TypeName).........下面是其它的列啊。 )