Click here to Skip to main content
14,877,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In which
1. First repeater is bind with a single row data source
2. Second repeater is bind with a multiple rows data source.
3. Third repeater is again bind with a single row data source.

in details
Suppose.....
a. First Data Source is contain School Info Like School Name,Address,contact No & etc.
b. Second Data Source contain multiple Student records such as Name ,Father Name ,Mother Name,Class,Stream,Section & Roll No
c. Third Data Source contain Exam Time Table for a particular class such as Exam Date,Day,Subject Name,Type,Exam Shift,Exam Start Time & End Time.
Posted
Comments
   
What have you tried? Where is the issue?

1 solution

<asp:Repeater ID="Parent_Repeater" runat="server"
onitemdatabound="Parent_Repeater_ItemDataBound">

<HeaderTemplate><table bgcolor="#E6AF93" width="1100px"><tr><td colspan="6" align="center">
<asp:Label ID="Label28" runat="server" Text="Customer Report" ForeColor="Black"></asp:Label></td></tr></table></HeaderTemplate>
<ItemTemplate>

<table bgcolor="#FCFCFC" width="1100px" border="1" bordercolor="black" >

<tr><td colspan="6" align="center">
<asp:Label ID="Label30" runat="server" Text="Level: " CssClass="txtt"></asp:Label>
<asp:Label ID="Label29" runat="server" Text='<%#Eval ("promotion_name") %>' Font-Bold="true" ForeColor="Black"></asp:Label></td></tr>
<tr><td colspan="6" height="20px"></td></tr>
<tr>

<td width="175px">
<asp:Label ID="Label1" CssClass="txtt" runat="server" Text="Customer Name"></asp:Label>
</td>
<td width="175px">
<asp:Label ID="Label27" Visible="false" runat="server" Text='<%#Eval ("user_id") %>' CssClass="txtt"></asp:Label>

<asp:Label ID="Label2" runat="server" Text='<%#Eval ("name") %>' CssClass="txtt"></asp:Label>
</td>
<td width="200px">
<asp:Label ID="Label3" CssClass="txtt" runat="server" Text="Product Name"></asp:Label>
</td>
<td width="200px">
<asp:Label ID="Label4" runat="server" CssClass="txtt" Text='<%#Eval ("product_name") %>'></asp:Label>
</td>
<td width="175px">
<asp:Label ID="Label5" runat="server" CssClass="txtt" Text="User Name"></asp:Label>
</td>
<td width="175px">
<asp:Label ID="Label6" runat="server" CssClass="txtt" Text='<%#Eval ("username") %>'></asp:Label>
</td>
</tr>
<tr>
<td width="175px">
<asp:Label ID="Label7" runat="server" CssClass="txtt" Text="Date of Join"></asp:Label>
</td>
<td width="175px">
<asp:Label ID="Label8" runat="server" CssClass="txtt" Text='<%#Eval ("date_Of_join","{0:dd/MM/yyyy}") %>'></asp:Label>
</td>
<td width="200px">
<asp:Label ID="Label9" runat="server" CssClass="txtt" Text="Product Price"></asp:Label>
</td>
<td width="200px">
<asp:Label ID="Label10" runat="server" CssClass="txtt" Text='<%#Eval ("product_price") %>'></asp:Label>
</td>
<td width="175px">
<asp:Label ID="Label11" runat="server" CssClass="txtt" Text="Password"></asp:Label>
</td>
<td width="175px">
<asp:Label ID="Label12" runat="server" CssClass="txtt" Text='<%#Eval ("password") %>'></asp:Label>
</td>
</tr>


<tr>
<td colspan="6">
<br />
<center>
<asp:Repeater ID="Child_Repeater" runat="server">
<HeaderTemplate><table width="1050px" bgcolor="#F2D7C9" border="1">
<tr>
<td width="150px">
<asp:Label ID="Label13" CssClass="txtt" runat="server" Text="Level"></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label14" CssClass="txtt" runat="server" Text="Customer Name"></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label15" CssClass="txtt" runat="server" Text="Date of Join"></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label16" CssClass="txtt" runat="server" Text="Product Name"></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label17" CssClass="txtt" runat="server" Text="Product Price"></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label18" CssClass="txtt" runat="server" Text="User Name"></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label19" CssClass="txtt" runat="server" Text="Password"></asp:Label>
</td>
</tr>
</table></HeaderTemplate>
<ItemTemplate>
<table width="1050px" bgcolor="white" border="1">
<tr>
<td width="150px">
<asp:Label ID="Label20" CssClass="txtt" runat="server" Text='<%#Eval ("promotion_name") %>'></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label21" CssClass="txtt" runat="server" Text='<%#Eval ("name") %>'></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label22" CssClass="txtt" runat="server" Text='<%#Eval ("date_Of_join","{0:dd/MM/yyyy}") %>'></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label23" CssClass="txtt" runat="server" Text='<%#Eval ("product_name") %>'></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label24" CssClass="txtt" runat="server" Text='<%#Eval ("product_price") %>'></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label25" CssClass="txtt" runat="server" Text='<%#Eval ("username") %>'></asp:Label>
</td>
<td width="150px">
<asp:Label ID="Label26" CssClass="txtt" runat="server" Text='<%#Eval ("password") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</center>
<br />
</td>
</tr>
</table>
<br />
</ItemTemplate>


</asp:Repeater>





In C#,
con.Open();
SqlDataAdapter adp3=new SqlDataAdapter("select * from table1",con);
adp3.Fill(ds);
Parent_Repeater.DataSource = ds;
Parent_Repeater.DataBind();


Bind all child Repeater in Parent Repeater item Databound,

protected void Parent_Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{

Label lbl_userid = (Label)e.Item.FindControl("Label27");
id = int.Parse(lbl_userid.Text);

Repeater Chi_Repeat = (Repeater)e.Item.FindControl("Child_Repeater");
con.Open();
dataset ds1;
SqlDataAdapter adp1=new SqlDataAdapter("select * from table2",con);
adp1.Fill(ds1);
Chi_Repeat.DataSource = ds1;
Chi_Repeat.DataBind();nd();
}

}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
   
v2
Comments
Rajesh waran 9-Oct-14 2:10am
   
This is my Nested Repeater, Edit this Parent and Child Repeater as per your needs.
In my Repeater i have used 1 parent and 1 Child Repeater,if you need more than 1,you can add as per your needs.
It's seems like a Datalist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900