SELECT category_Sn,isnull(count,0) FROM category left join (SELECT count(*) as count,category_Sn FROM [article] group by category_Sn) AS [article] on category.[category_Sn]=article.[category_Sn] 。
用左外连接
------------------页面代码------------------ <asp:DataList ID="DataList2" RepeatColumns="2" runat="server" OnItemDataBound="DataList2_ItemDataBound" DataKeyField="id"> <ItemTemplate> <%# Eval("typename") %> <asp:DataList ID="DataList3" runat="server"> <ItemTemplate> <%# Eval("articletitle") %> </ItemTemplate> </asp:DataList> </ItemTemplate> </asp:DataList> ------------------后台代码加上如下方法------------------ protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e) { int id =Convert.ToInt32(DataList2.DataKeys[e.Item.ItemIndex].ToString()); string articlesql = "SELECT * FROM article where booktypeid="+id; ole_adpt = new OleDbDataAdapter(articlesql , oleconn); DataSet ds3 = new DataSet(); ole_adpt.Fill(ds3, "article"); DataList3.DataSource = ds3.Tables["article"].DefaultView; DataList3.DataBind(); }。
首先 类之间是可以嵌套的。
其次 内部类一般常用的有:
1、普通内部类 即:直接在一个类的内部定义另外一个类。
创建内部类时,外部类的对象必须已经创建 。
即:例子
public class Class1{。
int i;。
class Inner{。
static int j;//这是错误的。
int j;//正确。
private void getData() {。
i = 2;。
}
}
}
Class1.Inner inner = new StringSplit().new Inner();。
实例内部类会持有外部类的引用。
即:上例中的 i = 2;等价于 Class1.this.i = 2;。
实例内部类不能定义static静态成员变量,只能定义实例成员变量。
2、静态内部类
不会持有外部类的引用,若要使用外部类的成员变量,则需生成外部类的对象。
创建时可以没有外部类的实例 即:
public class Class1{。
static int i;。
int k;。
static class Inner{。
static int j;//这是错误的。
int j;//正确。
private void getData() {。
i = 2;//上面i为静态,此处正确,否则错误。
Class1 class1 = new Class1();。
class1.k;//正确。
}
}
}
Class1.Inner inner = new Class1.Inner();。
可以访问外部类的静态变量。
表格么, 去看看tabu宏包, 方法及例子去看宏包文档, 命令行运行 texdoc tabu即可找到宏包文档。
在JAVA语言中,在同一个类里面,方法是不能嵌套使用的,但是可以相互调用使用。