((DataList)this.dlRptCategory.FindControl("dlRptGoods")).Items[i].FindControl("hlGoToBuy"); 通過這句可以嗎? 然后怎么將這個控件實例化為HyperLink類型的?
2 回答

慕虎7371278
TA貢獻1802條經(jīng)驗 獲得超4個贊
dlRptCategory.DataSource = 數(shù)據(jù)源;
dlRptCategory.DataBind();
for (int i = 0; i < dlRptCategory.Items.Count; i++)
{
// 獲得內(nèi)嵌的DataList
DataList dlRptGoods= (DataList)dlRptCategory.Items[i].FindControl("dlRptGoods");
// 綁定子模塊
dlRptGoods.DataSource = 數(shù)據(jù)源;
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 ,應(yīng)該是父.Items[i].FindControl
- 2 回答
- 0 關(guān)注
- 515 瀏覽
添加回答
舉報
0/150
提交
取消