C# 如何取得批量动态输出的textbox的id???
生成时是绑定好数据的,修改后在批量更新到数据库中,更新语句怎么写啊?

解决方案 »

  1.   

    textbox是Control控件,遍历Control控件,看看是否是TextBox类型,是的话,就把控件ID输出
      

  2.   

                foreach (Control c in this.Controls)
                {
                    if (c.GetType() == "TextBox")
                    {
                        ....
                    }
                }
      

  3.   


    foreach (Control c in this.Controls)
                {
    if   (x   is   TextBox)   
      {  
    ..........
    }
                }
     
      

  4.   

    foreach (Control c in this.Controls)
                {
                    if (c.GetType().Name == "TextBox")
                    {
                        c.Name = "xxxxxx";
                        c.Text = string.Empty;                }
                }
      

  5.   

     IList <Control> TT = new List <Control>();             GetControls(this, TT); 
                for (int i = 0; i != TT.Count; i++) 
                { 
                    MessageBox.Show(TT[i].Name); 
                } 
     
     public static void GetControls(Control p_Control, IList<Control> p_SubControlList)
            {
                foreach (Control _SubControl in p_Control.Controls)
                {
                    if (_SubControl is TextBox)
                    {
                        p_SubControlList.Add(_SubControl);
                        GetControls(_SubControl, p_SubControlList);
                    }
                }
            }
      

  6.   

    参考一下:
    http://blog.csdn.net/linaren/archive/2009/03/04/3957463.aspx