Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have used 3 level nested repeater and i want to access id value (which is used in Grand parent Repeater) in child repeater from grand parent repeater.
Posted
Updated 18-Mar-15 2:31am
v2
Comments
Where is the issue?
Arkadeep De 18-Mar-15 14:24pm    
share the code pls. where you have stuck?
Member 10726045 19-Mar-15 1:21am    
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Repeater1.DataSource = getcontinent();
Repeater1.DataBind();
}
}
private DataTable getcontinent()
{
DataTable dt = u.gtcont();
return dt;
}

private DataTable getnews(int con_id,string date)
{

string sql = "SELECT top 2 News_title FROM tbl_news WHERE News_continent_id='" + con_id + "' and cast(News_createdate as Date)='" + date + "' order by [News_id] Desc";
SqlCommand cmd = new SqlCommand(sql, cs.GetConnection());
cs.OpenConnection();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
cs.CloseConnection();
return dt;
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DataRowView drv = (DataRowView)e.Item.DataItem;
int con_id = Convert.ToInt32(drv["con_id"]);
Repeater Repeater3 = (Repeater)e.Item.FindControl("Repeater3");
Repeater3.DataSource = u.gtdate(con_id);
Repeater3.DataBind();

}
protected void Repeater3_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DataRowView drv = (DataRowView)e.Item.DataItem;
DateTime date = Convert.ToDateTime(drv["News_createdate"]);
//int con_id = Convert.ToInt32(dr["con_id"]);
string dt = date.ToString("yyyy/MM/dd");
Repeater Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
Repeater2.DataSource = getnews(con_id, dt);
Repeater2.DataBind();
}

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "lnkclick")
{
Label lbl = (Label)e.Item.FindControl("titleLabel");
int i = u.get_cid(lbl.Text);
Response.Redirect("news1.aspx?id=" + i);
}
}

Here hierarchy is like this:

Repeater1 -> Repeater3 -> Repeater2

I want to get con_id value from Repeater1 to Repeater2

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