像这样,获取不到,估计是获取第一个textbox的值:
string repalycontent = "";
       RepeaterItem rm = (RepeaterItem)((System.Web.UI.Control)sender).Parent;
       repalycontent = ((TextBox)(rm).FindControl("TextBox1")).Text.ToString().Trim();         for (int i = 0; i < Repeater1.Items.Count; i++)
        {
            TextBox lbl = (TextBox)Repeater1.Items[i].FindControl("TextBox1");
            repalycontent = lbl.Text.ToString();
        }正确的写法是什么样的呢,谢谢咯

解决方案 »

  1.   

    String lbl = ((TextBox)Repeater1.Items[i].FindControl("TextBox1").Text).Tostring();
    你那样获取也是对的  你要看看你获取的TextBox里面有没有值哦。。
      

  2.   

    你上面的肯定是最后一行的TextBox1的值!~。。你可以绑定上ItemIndex,通过ItemIndex找出是哪一行。
    然后通过
    TextBox lbl = (TextBox)Repeater1.Items[i].FindControl("TextBox1");//i变为你获取的行index
    repalycontent = lbl.Text.ToString();
      

  3.   

    楼上2位大虾,问题是我怎么获取当前行的索引,里面的那个textbox是有值的,但每次取的时候都是空字符串。
      

  4.   

    结构如何
    for (int i = 0; i < Repeater1.Items.Count; i++)
            {
                TextBox lbl = Repeater1.Items[i].FindControl("TextBox1") as TextBox;
            }
    RepeaterItem item =(RepeaterItem) ((Button)sender).Parent;
      TextBox  l = (TextBox)item.FindControl("TextBox1 ");
      

  5.   

    有个笨办法 每一行放个LABLE 隐藏 存什么值你懂得 
      

  6.   

    楼上的 还是得判断当前点击的是哪行commandA...哪啥已经被占用咯
      

  7.   

    如果是 B/S 的 可考虑前台传值至后台,如果 C/S 的 可用4楼方法,觉得可行。