本篇文章为大家展示了如何在ASP.Net中嵌套使用数据展示控件,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
ASP.NET 是开源,跨平台,高性能,轻量级的 Web 应用构建框架,常用于通过 HTML、CSS、JavaScript 以及服务器脚本来构建网页和网站。
前台代码:
<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关联的数据项 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 = "领导日程管理系统"; syslog.Location = "Repeater绑定数据:OtherSchedule.aspx"; syslog.Message = "页面信息加载异常:" + ex.Message; syslog.DataSource = 0; logprovider.AddAuditRecordToSource(syslog); } }
上述内容就是如何在ASP.Net中嵌套使用数据展示控件,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。