Hi,I have done nested repeater Control.but the output what i want am unable to get that.Kindly help me out.Here Is My Complete Code:Source Code:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReptrinsidReptr.aspx.cs" Inherits="Mystuff.Controls.ReptrinsidReptr" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound"> <HeaderTemplate> <div style="background:Yellow"> <asp:Label ID="Label1" runat="server" Text="Name" Width="32%" ForeColor="Fuchsia"></asp:Label> <asp:Label ID="Label2" runat="server" Text="Designation" Width="32%" ForeColor="Fuchsia"></asp:Label> <asp:Label ID="Label3" runat="server" Text="Location" Width="32%" ForeColor="Fuchsia"></asp:Label> </div> </HeaderTemplate> <ItemTemplate> <div style="background:Yellow"> <asp:TextBox ID="Label4" runat="server" Text='<%#Eval("Name") %>' Width="32%" BackColor="Cyan"></asp:TextBox> <asp:TextBox ID="Label5" runat="server" Text='<%#Eval("Designation") %>' Width="32%" BackColor="Cyan"></asp:TextBox> <asp:TextBox ID="Label6" runat="server" Text='<%#Eval("Location") %>' Width="32%" BackColor="Cyan"></asp:TextBox> </div> <asp:Repeater ID="Repeater2" runat="server" > <HeaderTemplate> <div style="background:Red"> <asp:Label ID="Label4" runat="server" Text="Employee" Width="32%"></asp:Label> <asp:Label ID="Label5" runat="server" Text="Position" Width="32%"></asp:Label> <asp:Label ID="Label6" runat="server" Text="City" Width="32%"></asp:Label> </div> </HeaderTemplate> <ItemTemplate> <div style="background:Yellow"> <asp:TextBox ID="TextBox4" runat="server" Text='<%#Eval("Employee") %>' Width="32%"></asp:TextBox> <asp:TextBox ID="TextBox5" runat="server" Text='<%#Eval("Position") %>' Width="32%"></asp:TextBox> <asp:TextBox ID="TextBox6" runat="server" Text='<%#Eval("City") %>' Width="32%"></asp:TextBox> </div> </ItemTemplate> </asp:Repeater> </ItemTemplate> </asp:Repeater> </form> </body> </html>
Code Behind:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;namespace Mystuff.Controls{public partial class ReptrinsidReptr : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){DataTable dt1 = new DataTable();dt1.Columns.Add("Name");dt1.Columns.Add("Designation");dt1.Columns.Add("Location");DataRow rw1 = dt1.NewRow();rw1["Name"] = "A";rw1["Designation"] = ".NetDeveloper";rw1["Location"] = "Delhi";dt1.Rows.Add(rw1);DataRow rw2 = dt1.NewRow();rw2["Name"] = "B";rw2["Designation"] = "Trainee";rw2["Location"] = "UP";dt1.Rows.Add(rw2);DataRow rw3 = dt1.NewRow();rw3["Name"] = "C";rw3["Designation"] = "JavaDeveloper";rw3["Location"] = "Bombay";dt1.Rows.Add(rw3);Repeater1.DataSource = dt1;Repeater1.DataBind();}protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e){if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem){Repeater Repeater2 = (Repeater)(e.Item.FindControl("Repeater2"));DataTable dt2 = new DataTable();dt2.Columns.Add("Employee");dt2.Columns.Add("Position");dt2.Columns.Add("City");DataRow rw1 = dt2.NewRow();rw1["Employee"] = "D";rw1["Position"] = "Developer";rw1["City"] = "USA";dt2.Rows.Add(rw1);DataRow rw2 = dt2.NewRow();rw2["Employee"] = "E";rw2["Position"] = "Trainee";rw2["City"] = "Delhi";dt2.Rows.Add(rw2);DataRow rw3 = dt2.NewRow();rw3["Employee"] = "F";rw3["Position"] = "Sr Developer";rw3["City"] = "Bombay";dt2.Rows.Add(rw3);Repeater2.DataSource = dt2;Repeater2.DataBind();}}}}Could anyone make me correct.if i open outer repeater inner repeater should Open.I have done as i Mentioned above.am i wrong anywhere.