ASP.Net中數(shù)據(jù)展示控件的嵌套使用示例
1,工作中遇到這樣一個(gè)需求,頁(yè)面上要把所有的User加載出來(lái),同時(shí)每個(gè)User后面緊跟著要把User的任務(wù)加載出來(lái)!我的處理方法是用Repeater來(lái)加載所有的User,同時(shí)在Repeater里面嵌套一個(gè)GridView,將每個(gè)User的任務(wù)展示出來(lái)!代碼如下
前臺(tái)代碼:
<asp:Repeater ID="Repeater1" runat="server"
onitemdatabound="Repeater1_ItemDataBound">
<HeaderTemplate>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
</HeaderTemplate>
<ItemTemplate>
<td class="list_table_in">
<span class="leaderTitle">高管:<a href='/LeaderSchedule/_layouts/LS/LeaderDetail.aspx?loginName=<%#Eval("LoginName") %>'><%#Eval("UserName") %></a></span><asp:GridView ID="gv_InRep" runat="server" AutoGenerateColumns="False" AllowSorting="True"
OnRowCreated="GV_DoneList_RowCreated" OnSorting="GV_DoneList_Sorting" AllowPaging="True"
CssClass="tasklisttbl" Width="100%" OnRowDataBound="GV_DoneList_RowDataBound"
EnableModelValidation="True">
<AlternatingRowStyle BackColor="#FDFEFF" />
<HeaderStyle HorizontalAlign="Center" ForeColor="Black" Height="20" />
<RowStyle HorizontalAlign="Center" Height="26px" />
<Columns>
<asp:BoundField HeaderText="日期" ItemStyle-CssClass="custom" DataField="Date" SortExpression="Date">
<ItemStyle Width="15%" />
</asp:BoundField>
<asp:BoundField HeaderText="時(shí)間" DataField="Time" SortExpression="Time">
<ItemStyle Width="11%" />
</asp:BoundField>
<asp:BoundField HeaderText="工作安排" DataField="WorkPlan" SortExpression="WorkPlan">
<ItemStyle Width="11%" />
</asp:BoundField>
<asp:BoundField HeaderText="地點(diǎn)" DataField="Place" SortExpression="Place">
<ItemStyle Width="11%" />
</asp:BoundField>
</Columns>
<PagerTemplate>
</PagerTemplate>
</asp:GridView>
</td>
<asp:Literal ID="Literal1" runat="server" Text='<%#Eval("Flag") %>'></asp:Literal>
</ItemTemplate>
<FooterTemplate>
</tr></table>
</FooterTemplate>
</asp:Repeater>
后臺(tái)代碼:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
GridView gv = e.Item.FindControl("gv_InRep") as GridView;//找到里層的repeater對(duì)象
Leader rowv = (Leader)e.Item.DataItem;//找到分類Repeater關(guān)聯(lián)的數(shù)據(jù)項(xiàng)
string typeid = rowv.LoginName; //獲取填充子類的id
SetSorting();
gv.DataSource = PointDataSource(typeid);
gv.DataBind();
}
}
catch (Exception ex)
{
SysLog syslog = new SysLog();
syslog.ListName = ConstData.ListName_PCITC_LS_Schedule;
syslog.LType = "Repeater的Item綁定事件異常";
syslog.WorkFlowName = "領(lǐng)導(dǎo)日程管理系統(tǒng)";
syslog.Location = "Repeater綁定數(shù)據(jù):OtherSchedule.aspx";
syslog.Message = "頁(yè)面信息加載異常:" + ex.Message;
syslog.DataSource = 0;
logprovider.AddAuditRecordToSource(syslog);
}
}
- ASP.NET中repeater嵌套實(shí)現(xiàn)代碼(附源碼)
- ASP.NET中Form表單不可以嵌套使用
- asp.net實(shí)現(xiàn)DataList與Repeater嵌套綁定的方法
- 在ASP.NET 2.0中操作數(shù)據(jù)之二十六:排序自定義分頁(yè)數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之二十七:創(chuàng)建自定義排序用戶界面
- 在ASP.NET 2.0中操作數(shù)據(jù)之二十八:GridView里的Button
- 在ASP.NET 2.0中操作數(shù)據(jù)之二十九:用DataList和Repeater來(lái)顯示數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之三十:格式化DataList和Repeater的數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之三十一:使用DataList來(lái)一行顯示多條記錄
- 在ASP.NET 2.0中操作數(shù)據(jù)之三十二:數(shù)據(jù)控件的嵌套
相關(guān)文章
利用Service Fabric承載eShop On Containers的實(shí)現(xiàn)方法
下面小編就為大家分享一篇利用Service Fabric承載eShop On Containers的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-01-01
.net MVC使用IPrincipal進(jìn)行Form登錄即權(quán)限驗(yàn)證(3)
這篇文章主要為大家詳細(xì)介紹了.net MVC使用IPrincipal進(jìn)行Form登錄即權(quán)限驗(yàn)證,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04
.NET微信小程序用戶數(shù)據(jù)的簽名驗(yàn)證和解密代碼
這篇文章主要介紹了.NET微信小程序用戶數(shù)據(jù)的簽名驗(yàn)證和解密代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12
.NET Core 2.0 Preview2 發(fā)布匯總
這篇文章主要為大家詳細(xì)介紹了.NET Core 2.0 Preview2 發(fā)布匯總的相關(guān)內(nèi)容,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06
linq to sql中,如何解決多條件查詢問(wèn)題,答案,用表達(dá)式樹(shù)!
有個(gè)小項(xiàng)目中,用到了linq to sql,既然這樣,想必需要做多條件組合查詢了,雖然我對(duì)表達(dá)式樹(shù)的研究也只是寥寥地,但除此方法,似乎別無(wú)他法,只好硬著頭皮研究一下.2011-08-08
asp.net中關(guān)于dropdwonlist無(wú)法獲得值問(wèn)題
用dropdwonlist綁定了一個(gè)數(shù)據(jù)源做選擇,但是當(dāng)提交時(shí),用控件屬性無(wú)法獲得相應(yīng)的值,打印出來(lái)每次都是顯示的第一個(gè)值2011-11-11
asp.net GridView 刪除時(shí)彈出確認(rèn)對(duì)話框(包括內(nèi)容提示)
GridView 刪除時(shí)彈出確認(rèn)對(duì)話框(包括內(nèi)容提示)2009-12-12
ScriptManager.RegisterStartupScript()方法在ajax頁(yè)面無(wú)效的解決方法
ScriptManager.RegisterStartupScript()方法在ajax頁(yè)面無(wú)效的解決方法2010-03-03

