Repeater模板里面的有个服务器控件txtUrlame
在Repeater.ItemCommand事件里,这样取
((TextBox)this.FindControl("txtUrlame")).Text.Trim()
System.NullReferenceException: 未将对象引用设置到对象的实例。
是找不到该控件,还是说明原因?

解决方案 »

  1.   

    for(int i=0; i < Repeater.Items.Count;i++) 

    TextBox txt = (TextBox) Repeater.Items[i].FindControl("txtUrlame"); 

      

  2.   

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) 
        { 
    TextBox tb=e.Item.FindControl("txtUrlame") as TextBox;
    String aa=tb.Text;
    }
      

  3.   


    string value = ((TextBox)e.Item.FindControl("txtUrlName")).Text.ToString();
      

  4.   


    //Repeater1_ItemDataBound
    foreach(RepeaterItem ri In Repeater1.Items) 

      TextBox tb=ri.FindControl("txtUrlame") as TextBox; 
      string aa=tb.Text; 
    }protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) 
        { 
    TextBox tb=e.Item.FindControl("txtUrlame") as TextBox; 
    String aa=tb.Text; 
    }
      

  5.   

    http://blog.csdn.net/xianfajushi/archive/2008/11/30/3413317.aspx