((DataList)this.dlRptCategory.FindControl("dlRptGoods")).Items[i].FindControl("hlGoToBuy"); 通过这句可以吗? 然后怎么将这个控件实例化为HyperLink类型的?
2 回答

慕虎7371278
TA贡献1802条经验 获得超4个赞
dlRptCategory.DataSource = 数据源;
dlRptCategory.DataBind();
for (int i = 0; i < dlRptCategory.Items.Count; i++)
{
// 获得内嵌的DataList
DataList dlRptGoods= (DataList)dlRptCategory.Items[i].FindControl("dlRptGoods");
// 绑定子模块
dlRptGoods.DataSource = 数据源;
dlRptGoods.DataBind();
for(int i=0; i<dlRptGoods.Items.Count; i++)
{
dlRptGoods.Items[i].FindControl("hlGoToBuy")
}
}
公式:((DataList)父.Items[i].FindControl("子id")).Items[i].FindControl("hlGoToBuy")
你的错误是:父.FindControl ,应该是父.Items[i].FindControl
- 2 回答
- 0 关注
- 506 浏览
添加回答
举报
0/150
提交
取消