点击详细:展示详细内嵌套的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; } } }
时间: 2024-10-27 00:30:29