日期:2014-05-17 浏览次数:20493 次
using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; public partial class type_pro : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bingrpt(); } } /// <summary> /// 分类 /// </summary> protected void bingrpt() { int id = Convert.ToInt32(Request.QueryString["id"].ToString()); string strqry = ""; strqry = "select * From T_PatentsType where id =" + id + " order by id asc"; DataView dvlist = DBFun.GetDataView(strqry); rpt_fenlei.DataSource = dvlist; rpt_fenlei.DataBind(); } /// <summary> /// 子项绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rpt_fenlei_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater rpt_info = (Repeater)e.Item.FindControl("rpt_info"); // 找到分类Repeater关联的数据项 DataRowView rowv = (DataRowView)e.Item.DataItem; // 提取分类ID int CategorieId = Convert.ToInt32(rowv["id"]); //根据分类ID查询该分类下的产品,并绑定产品Repeater string strqry = ""; strqry = "select top 20 * From T_Patents where typeid=" + CategorieId + " order by id desc"; DataView dvlist = DBFun.GetDataView(strqry); rpt_info.DataSource = dvlist; rpt_info.DataBind(); } } /// <summary> /// 顺序控件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void AspNetPager1_PageChanged(object sender, EventArgs e) { rpt_fenlei.DataBind(); } }
你这里的Repeater id为rpt_info Repeater rpt_info = (Repeater)e.Item.FindControl("rpt_info"); // 找到分类Repeater关联的数据项 而你后面绑定 GridView1.DataSource = pds; GridView1.DataBind(); 能不报错!