//定义一个DataTable protected static DataTable Class2_DataTable = new DataTable(); //当页面第一次加载时候从数据库提取所有二级栏目的DataTable填充到Class2_DataTable里面 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ClassBLL _ClassBll = new ClassBLL(); Class2_DataTable = _ClassBll.BLL_GetData_DB_Class2(); } } //这样每次执行到Repeater_Class2时候只需要从Class2_DataTable里面通过RowFilter //提取本一级栏目分类的数据就行了,整个页面只需要查询数据库二次就能够提取所有数据 protected DataTable GetClass2(int Class1) { DataTable Class2_DataTable_RowFilter = Class2_DataTable; Class2_DataTable_RowFilter.DefaultView.RowFilter = "Class = " + Class1; return Class2_DataTable_RowFilter; } |