关于Repeater 的四星级难题,求教高手
protected void rptFoodList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataSet ds = new DataSet();
Repeater rptFood = (Repeater)e.Item.FindControl( "rptFood ");
//找到分类Repeater关联的数据项
DataRowView rowv = (DataRowView)e.Item.DataItem;
//提取分类ID
int FoodSortID = Convert.ToInt32(rowv[ "FoodSortID "]);
//根据分类ID查询该分类下的产品,并绑定产品Repeater
ds = DataService.ShowFood(FoodSortID);
rptFood.DataSource = ds.Tables[0];
if(i%2==0)
{
e.Item.Controls.Add(new LiteralControl( " </tr> <tr> "));
}
i++;
rptFood.DataBind();
}
}
我在rptFoodList里面嵌套了个rptFood
我要输出些html脚本给rptFood
我用了上面代码的这句:
e.Item.Controls.Add(new LiteralControl( " </tr> <tr> "));
但是,它却给了 rptFoodList 而不是rptFood
请问:我该怎样写才能给到rptFood 谢谢!
------解决方案--------------------何必在cs文件里面写?
直接 <SeparatorTemplate> </tr> <td> </SeparatorTemplate>
不是更好吗