首页 新闻 会员 周边

嵌套Datalist控件,如何找到里层Datalist内的控件?

0
悬赏园豆:15 [已解决问题] 解决于 2009-04-01 14:31

((DataList)this.dlRptCategory.FindControl("dlRptGoods")).Items[i].FindControl("hlGoToBuy");

 

通过这句可以吗? 然后怎么将这个控件实例化为HyperLink类型的?

Mr.Cantus的主页 Mr.Cantus | 初学一级 | 园豆:24
提问于:2009-03-28 23:22
< >
分享
最佳答案
0

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

Fencer | 初学一级 |园豆:7 | 2009-03-29 12:26
万分感谢!虽然我找的不是这个问题,但给了我另一个问题提供了思路!
Ryan-Xu | 园豆:200 (初学一级) | 2009-09-02 13:34
其他回答(1)
0

 可以 .就是这么用啊。

你这个是repeater是把..

邢少 | 园豆:10926 (专家六级) | 2009-03-29 09:18
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册