asp.net repeater1中 嵌套repeater2 数据源查询的一个条件值 是repeater1的一个值,周末绑定遍历
asp.netrepeater1中嵌套repeater2数据源查询的一个条件值是repeater1的一个值,周末绑定遍历...
asp.net repeater1中 嵌套repeater2 数据源查询的一个条件值 是repeater1的一个值,周末绑定遍历
展开
1个回答
展开全部
repeater2 数据源查询的一个条件值 是repeater1的一个值,这个值是跟repeater2 在同一行的吗?
如果是的话可以使用repeater1的itemdatabound事件来绑定
protected voidrepeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Label lblJobCategoryID = e.Item.FindControl("lblJobCategoryID") as Label;
Label lblCategoryName = e.Item.FindControl("lblCategoryName") as Label;
Jobcategory EntityJobCategory = new Jobcategory();
Repeater repeater2= e.Item.FindControl("repeater2") as Repeater;
var source = EntityJobCategory.GetJobCategoryContact(lblJobCategoryID.Text.ToInt());
repeater2.DataSource = source;
repeater2.DataBind();
}
}
如果不是的话只能绑定完repeater1之后遍历整个repeater1
foreach (GridViewRow gdrow in repeater1.Rows)
{
Label lblJobCategoryID = gdrow.FindControl("lblJobCategoryID") as Label;
Label lblCategoryName = gdrow.FindControl("lblCategoryName") as Label;
Jobcategory EntityJobCategory = new Jobcategory();
Repeater repeater2= gdrow.FindControl("repeater2") as Repeater;
var source = EntityJobCategory.GetJobCategoryContact(lblJobCategoryID.Text.ToInt());
repeater2.DataSource = source;
repeater2.DataBind();
}
如果是的话可以使用repeater1的itemdatabound事件来绑定
protected voidrepeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Label lblJobCategoryID = e.Item.FindControl("lblJobCategoryID") as Label;
Label lblCategoryName = e.Item.FindControl("lblCategoryName") as Label;
Jobcategory EntityJobCategory = new Jobcategory();
Repeater repeater2= e.Item.FindControl("repeater2") as Repeater;
var source = EntityJobCategory.GetJobCategoryContact(lblJobCategoryID.Text.ToInt());
repeater2.DataSource = source;
repeater2.DataBind();
}
}
如果不是的话只能绑定完repeater1之后遍历整个repeater1
foreach (GridViewRow gdrow in repeater1.Rows)
{
Label lblJobCategoryID = gdrow.FindControl("lblJobCategoryID") as Label;
Label lblCategoryName = gdrow.FindControl("lblCategoryName") as Label;
Jobcategory EntityJobCategory = new Jobcategory();
Repeater repeater2= gdrow.FindControl("repeater2") as Repeater;
var source = EntityJobCategory.GetJobCategoryContact(lblJobCategoryID.Text.ToInt());
repeater2.DataSource = source;
repeater2.DataBind();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询