ASP.Net中數(shù)據(jù)展示控件的嵌套使用示例
1,工作中遇到這樣一個需求,頁面上要把所有的User加載出來,同時每個User后面緊跟著要把User的任務(wù)加載出來!我的處理方法是用Repeater來加載所有的User,同時在Repeater里面嵌套一個GridView,將每個User的任務(wù)展示出來!代碼如下
前臺代碼:
<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="時間" DataField="Time" SortExpression="Time"> <ItemStyle Width="11%" /> </asp:BoundField> <asp:BoundField HeaderText="工作安排" DataField="WorkPlan" SortExpression="WorkPlan"> <ItemStyle Width="11%" /> </asp:BoundField> <asp:BoundField HeaderText="地點" 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>
后臺代碼:
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對象 Leader rowv = (Leader)e.Item.DataItem;//找到分類Repeater關(guān)聯(lián)的數(shù)據(jù)項 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 = "頁面信息加載異常:" + ex.Message; syslog.DataSource = 0; logprovider.AddAuditRecordToSource(syslog); } }
- ASP.NET中repeater嵌套實現(xiàn)代碼(附源碼)
- ASP.NET中Form表單不可以嵌套使用
- asp.net實現(xiàn)DataList與Repeater嵌套綁定的方法
- 在ASP.NET 2.0中操作數(shù)據(jù)之二十六:排序自定義分頁數(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來顯示數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之三十:格式化DataList和Repeater的數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之三十一:使用DataList來一行顯示多條記錄
- 在ASP.NET 2.0中操作數(shù)據(jù)之三十二:數(shù)據(jù)控件的嵌套
相關(guān)文章
利用Service Fabric承載eShop On Containers的實現(xiàn)方法
下面小編就為大家分享一篇利用Service Fabric承載eShop On Containers的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01.net MVC使用IPrincipal進(jìn)行Form登錄即權(quán)限驗證(3)
這篇文章主要為大家詳細(xì)介紹了.net MVC使用IPrincipal進(jìn)行Form登錄即權(quán)限驗證,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-04-04.NET微信小程序用戶數(shù)據(jù)的簽名驗證和解密代碼
這篇文章主要介紹了.NET微信小程序用戶數(shù)據(jù)的簽名驗證和解密代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-12-12.NET Core 2.0 Preview2 發(fā)布匯總
這篇文章主要為大家詳細(xì)介紹了.NET Core 2.0 Preview2 發(fā)布匯總的相關(guān)內(nèi)容,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06linq to sql中,如何解決多條件查詢問題,答案,用表達(dá)式樹!
有個小項目中,用到了linq to sql,既然這樣,想必需要做多條件組合查詢了,雖然我對表達(dá)式樹的研究也只是寥寥地,但除此方法,似乎別無他法,只好硬著頭皮研究一下.2011-08-08asp.net中關(guān)于dropdwonlist無法獲得值問題
用dropdwonlist綁定了一個數(shù)據(jù)源做選擇,但是當(dāng)提交時,用控件屬性無法獲得相應(yīng)的值,打印出來每次都是顯示的第一個值2011-11-11asp.net GridView 刪除時彈出確認(rèn)對話框(包括內(nèi)容提示)
GridView 刪除時彈出確認(rèn)對話框(包括內(nèi)容提示)2009-12-12ScriptManager.RegisterStartupScript()方法在ajax頁面無效的解決方法
ScriptManager.RegisterStartupScript()方法在ajax頁面無效的解決方法2010-03-03