相思资源网 Design By www.200059.com
1,工作中遇到这样一个需求,页面上要把所有的User加载出来,同时每个User后面紧跟着要把User的任务加载出来!我的处理方法是用Repeater来加载所有的User,同时在Repeater里面嵌套一个GridView,将每个User的任务展示出来!代码如下
前台代码:
<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("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); } }
标签:
数据展示,嵌套
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无ASP.Net中数据展示控件的嵌套使用示例的评论...