Repeater巢狀繫結Repeater
C#:
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();
}
}
{//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();
}
}
aspx:
<table border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 5px" width="100%">
<asp:Repeater runat="server" ID="rptypelist" OnItemDataBound="rptypelist_ItemDataBound">
<ItemTemplate>
<tr>
<td class="fb">
<a href="Lists.aspx?Qtid=<%#Eval("qtid") %>"><%#Eval("qtypename") %></a> <span id="askCount_15"
class="date2">[<%#Eval("typecount")%>]</span>
</td>
</tr>
<tr>
<td>
<div id="askTop2_15" class="ask_list">
<asp:Repeater runat="server" ID="rpquestionlist">
<ItemTemplate>
<a href="Question.aspx?qid=<%#Eval("liftquestionid")%>">
<%#Eval("questiontitle")%></a><br />
</ItemTemplate>
</asp:Repeater>
</div>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
如果繫結的是物件Model:
protected void rptHomeHelpCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rptHomeHelp = (Repeater)e.Item.FindControl("rptHomeHelp");
//找到分類Repeater關聯的資料項
HiddenField hd_CategoryId = e.Item.FindControl("hd_CategoryId") as HiddenField;
//提取分類ID
//int CategorieId = Convert.ToInt32(hd_CategoryId.Value);
var helpCategoryInfo = e.Item.DataItem as HelpCategoryInfo;//找到分類Repeater關聯的資料項
if (helpCategoryInfo != null)
{
int CategorieId = helpCategoryInfo.CategoryID; //獲取填充子類的id
//根據分類ID查詢該分類下的產品,並繫結產品Repeater
string filter = " IsToHome=1 and categoryid =" + CategorieId + " ";
string argument = string.Empty;
string value = string.Empty;
string order = "[helpId],[TopLevel] desc";
int totalRecords = 0;
IHelp dal = Factory<IHelp>.Create("Help");
var data = dal.HelpList(filter, string.Empty, string.Empty, order, 1, 100, out totalRecords);
if (data != null)
{
rptHomeHelp.DataSource = data;
rptHomeHelp.DataBind();
}
}
}
}
相關文章
- Repeater中巢狀使用Repeater巢狀
- DataGrid中巢狀使用Repeater (轉)巢狀
- repeater中巢狀放入RadioButtonList巢狀
- asp.net中Repeater中巢狀Repeater來顯示跟外層Repeater資料相關的其他資訊ASP.NET巢狀
- C# 利用repeater 的巢狀 實現一個自己想要的 日曆頁面C#巢狀
- Repeater 的分頁 (摘自網路)
- 簡單的Repeater分頁程式碼
- 動態綁資料(Repeater控制元件控制元件
- Repeater控制元件的分頁實現控制元件
- aspnetpager+repeater+oracle實現分頁功能Oracle
- VS2005入門之Repeater、DataList
- C#控制元件之Repeater控制元件使用C#控制元件
- ASP.NET Web Forms – Repeater 控制元件簡介ASP.NETWebORM控制元件
- 在repeater中使用javascript作文字框的改變JavaScript
- 流量回放框架 jvm-sandbox-repeater 實踐二框架JVM
- ASP.NET中利用Repeater實現增刪改操作ASP.NET
- Repeater控制元件實現編輯、更新、刪除操作控制元件
- 在repeater、datalist控制元件中使用分頁功能 (轉)控制元件
- [20190506]檢視巢狀與繫結變數.txt巢狀變數
- asp.net Repeater控制元件內容上下滾動播放ASP.NET控制元件
- 給Repeater控制元件裡新增序號的5種方法控制元件
- ASP.NET中Repeater控制元件實現分頁功能ASP.NET控制元件
- Java巢狀類(NestedClasses)總結Java巢狀
- Repeater的ItemDataBound 事件中e.Item.DataItem 轉換問題事件AI
- Android:巢狀滑動總結Android巢狀
- python-if elif巢狀結構Python巢狀
- 母版頁裡面查詢Repeater內控制元件,並構造URL控制元件
- c、c++ 結構體的巢狀C++結構體巢狀
- less巢狀巢狀
- Datalist巢狀巢狀
- [jvm-sandbox-repeater 學習筆記][原理說明篇] 2 回放流程JVM筆記
- [jvm-sandbox-repeater 學習筆記][原理說明篇] 1 錄製流程JVM筆記
- [jvm-sandbox-repeater 學習筆記][入門使用篇] 2 配置說明JVM筆記
- 流量錄製回放工具jvm-sandbox-repeater入門篇——服務部署JVM
- jvm-sandbox-repeater 錄製存在自定義型別 java 方法時報錯 ClassNotFoundJVM型別Java
- Repeater在無資料記錄時顯示類似GridView空模板(EmptyDataTemplate)View
- 使用PagedDataSource類實現DataList和Repeater控制元件的分頁顯示 (轉)控制元件
- 集合框架-集合的巢狀遍歷(HashMap巢狀HashMap)框架巢狀HashMap