不懂.这个GridView貌似和数据无关是吗? 只是用来收集用户输入?GridView绑定到数据源(控件)时,GridView根据数据源的第一行建一个GridViewRow(这时触发RowCreated事件),然后把数据填充到建立的GridViewRow(这时发生RowDataBound),然后把填充好数据的GridViewRow加入到GridView这么一个过程.这种情况下如果想取得某个GridViewRow里用ItemTemplate定义的TextBox时,倒是可以用GridViewRow.FindControl("TextBoxID")这种方法.

解决方案 »

  1.   

    用普通的findcontrol不就可以了
      

  2.   

    用普通的FindControl取不到值的......
      

  3.   

                    GridViewRow rowSeparator = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
                    rowSeparator.BackColor = System.Drawing.Color.White;                TableCellCollection cells = e.Row.Cells;                TableCell separatorCell = new TableCell();                if (MyAdvanceList.Columns[0].Visible == true)
                    {
                        separatorCell.ColumnSpan = cells.Count;
                    }
                    else
                    {
                        separatorCell.ColumnSpan = cells.Count - 1;
                    }                separatorCell.HorizontalAlign = HorizontalAlign.Center;
                    separatorCell.BackColor = System.Drawing.Color.FromArgb(226, 226, 226);                separatorCell.ControlStyle.Height = 30;                rowSeparator.Cells.Add(separatorCell);                rowSeparator.Visible = true;                rowSeparator.ID = "UserMessages" + e.Row.ClientID.ToString();
                    Label myLiuyan = new Label();
                    myLiuyan.Text = "我的留言:";
                    TextBox mytb = new TextBox();
                    mytb.ID = "mytb";
                    mytb.CssClass = "LiuYan";
                    separatorCell.Controls.Add(myLiuyan);
                    separatorCell.Controls.Add(mytb);                MyAdvanceList.Controls[0].Controls.Add(rowSeparator);怎么取到myrb的值???
      

  4.   

     foreach (GridViewRow item in GridView1)
            {
                if (item.RowType = DataControlRowType.DataRow)
                {
                    string textBox的值 = (item.Cells["你要找的那列的索引"].FindControl("TextBoxID") as TextBox).Text.Trim();
                }
            }
    就 可以找到了
      

  5.   

    把GridView当成一个集合遍历一次就可以找到了