Repeater nested gridview, Master/Slave table display, repeatergridview
Click Details: displays detailed nested gridview information.
Display Effect:
Location: 0 |
Arrival Time: 2014-11-020 |
Recipient: Sign 0 |
Details |
|
|
Bureau: 1 |
Arrival date: 2014-11-021 |
Recipient: Sign 1 |
Details |
|
Time status |
Recipient |
2014-11-020 |
Sign 0 |
|
Bureau: 2 |
Arrival Time: 2014-11-022 |
Recipient: sign 2 |
Details |
|
|
Bureau: 3 |
Arrival Time: 2014-11-023 |
Recipient: sign 3 |
Details |
<Asp: UpdatePanel ID = "UpdatePanel1" runat = "server"> <ContentTemplate> <asp: repeater ID = "Repeater1" runat = "server"> <HeaderTemplate> <table> </HeaderTemplate> <ItemTemplate> <tr> <td> location: <% # Eval ("JdName") %> </td> <td> arrival time: <% # Eval ("JdTime ") %> </td> <td> recipient: <% # Eval ("JdJsr") %> </td> <asp: linkButton ID = "LinkButton1" OnCommand = "bindDetail" CommandArgument = '<% # Eval ("JdName") %> 'runat = "server"> details </asp: linkButton> </td> </tr> <td colspan = "1"> </td> <td colspan = "3"> <asp: gridView ID = "GridView1" Width = "100%" Visible = "false" AutoGenerateColumns = "false" runat = "server"> <Columns> <asp: boundField HeaderText = "time status" DataField = "JdTime"/> <asp: BoundField HeaderText = "recipient" 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 = "sign" + 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 = "sign" + 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 ;}}}
Can the nested gridview or repeater in the repeater teach? Easy way
1. Step 1: bind data to repeater first;
2. Step 2: There is a row bound to the event databanding under repeater. I forgot how to write it. Find the gridview control under this event, just like finding a common control;
3: Find the gridview control and bind it with data! Finished!
You should follow my ideas first. If you still have something you don't understand, continue to ask!
Net repeater nested gridview how to find the value of the lab control placed in the gridview
// Step 1: Use repeater to first find the GridView Control
GridView GD = (GridView) repeaterID. Items [0]. FindControl ("gridviewID ");
// Step 2: The gridview control is found. It is easy to find the lab of a row.
Label lbl = GD. Rows [0]. FindControl ("labelID ");
I found the lab value of the first column of the first row of the gridview IN THE repter;
I don't know how to ask. Why?