asp.net(C#)中Repeater嵌套绑定Repeater

2016-12-30 09:55:47来源:oschina作者:深圳大道人点击

Repeater嵌套Repeater的结构:一般写过的都能看懂吧


private void RpTypeBind()
{
//GetQuestionTypeAndCount() 返回一个datatable
this.rptypelist.DataSource = LiftQuestionCtr.GetQuestionTypeAndCount();
this.rptypelist.DataBind();
}
protected void rptypelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate,
//HeaderTemplate,,ItemTemplate,SeparatorTemplate)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("rpquestionlist") as Repeater;//找到里层的repeater对象
DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项
int typeid = Convert.ToInt32(rowv["qtid"]); //获取填充子类的id
rep.DataSource = LiftQuestionCtr.GetSomeQuestionsByTypeid(typeid, 2);
rep.DataBind();
}
}














"><%#Eval("qtypename") %> >[<%#Eval("typecount")%>]



最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台