首页 > 代码库 > Repeater嵌套gridview,主从表展示
Repeater嵌套gridview,主从表展示
点击详细:展示详细内嵌套的gridview信息。
显示效果:
局点:0 | 到货时间:2014-11-020 | 接收人:签0 | 详细 | ||||
局点:1 | 到货时间:2014-11-021 | 接收人:签1 | 详细 | ||||
| |||||||
局点:2 | 到货时间:2014-11-022 | 接收人:签2 | 详细 | ||||
局点:3 | 到货时间:2014-11-023 | 接收人:签3 | 详细 |
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <table> </HeaderTemplate> <ItemTemplate> <tr> <td> 局点:<%# Eval("JdName")%> </td> <td> 到货时间:<%# Eval("JdTime")%> </td> <td> 接收人:<%# Eval("JdJsr")%> </td> <td> <asp:LinkButton ID="LinkButton1" OnCommand="bindDetail" CommandArgument='<%# Eval("JdName")%>' runat="server">详细</asp:LinkButton> </td> </tr> <tr> <td colspan="1"></td> <td colspan="3"> <asp:GridView ID="GridView1" Width="100%" Visible="false" AutoGenerateColumns="false" runat="server"> <Columns> <asp:BoundField HeaderText="时间状态" DataField="JdTime" /> <asp:BoundField HeaderText="接收人" DataField="JdJsr" /> </Columns> </asp:GridView> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> </ContentTemplate> </asp:UpdatePanel>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bindJuDian(); } } protected void bindDetail(object sender, EventArgs e) { List<JuDianEnty> Data1 = new List<JuDianEnty>(); string sid = ((LinkButton)sender).CommandArgument; int ss = Convert.ToInt32(sid); for (int i = 0; i < ss; i++) { JuDianEnty model = new JuDianEnty(); model.JdName = "DT" + i; model.JdTime = System.DateTime.Now.ToString("yyyy-MM-dd") + i; model.JdJsr = "签" + i; Data1.Add(model); } int lindex = ((RepeaterItem)((LinkButton)sender).NamingContainer).ItemIndex; foreach (RepeaterItem item in Repeater1.Items) { GridView gv1 = item.FindControl("GridView1") as GridView; if (item.ItemIndex == lindex) { gv1.DataSource = Data1; gv1.DataBind(); gv1.Visible = true; } else { gv1.Visible = false; } } } protected void bindJuDian() { List<JuDianEnty> Data1 = new List<JuDianEnty>(); for (int i = 0; i < 4; i++) { JuDianEnty model = new JuDianEnty(); model.JdName = i.ToString(); model.JdTime = System.DateTime.Now.ToString("yyyy-MM-dd") + i; model.JdJsr = "签" + i; Data1.Add(model); } Repeater1.DataSource = Data1; Repeater1.DataBind(); }}public class JuDianEnty{ public JuDianEnty() { } private string _jdname; private string _jdtime; private string _jdjsr; public string JdName { set { _jdname = value; } get { return _jdname; } } public string JdTime { set { _jdtime = value; } get { return _jdtime; } } public string JdJsr { set { _jdjsr = value; } get { return _jdjsr; } }}
Repeater嵌套gridview,主从表展示
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。