asp.net,语言。
使用了datagrid,在后台中向datagrid中插入textbox
Dim txtGridTextBox1 As New TextBox()
txtGridTextBox1.ID = "txtA"
dgMain.Items((YY - 1) * 4 + 1).Cells(j - 1).Controls.Add(txtGridTextBox1)然后从数据库中查询数据写入,但是findcontrol不行,
CType(dgMain.Items((YY - 1) * 4 + 2).Cells(j - 1).FindControl("txtA"), TextBox).Text也不行。
使用
CType(dgMain.Items((YY - 1) * 4 + 1).Cells(j - 1).Controls(0), TextBox).Text = NulltoStr(dbReader("行事1"))
好用了。现在进行改动后,点击登陆按钮存入数据库
可是用循环取值的时候,用findcontrol还是找不到,再用
CType(dgMain.Items((YY - 1) * 4 + 1).Cells(j - 1).Controls(0), TextBox).Text 
提示index什么错误,于是换成Controls(1)或者Controls(2) 也不行请大家帮助我啊!
谢谢

解决方案 »

  1.   

    没看懂你想问什么
    VB C#差不多
      

  2.   

    写入textbox的时候,你改在生成textbox的时候就给控件付值,然后再添加到datagrid不一样吗。
    进行改动后,点击登陆按钮时候有没有动态生成控件阿
      

  3.   

    动态生成的控件,如果在叶面post之后不重新生成的话,当然找不到了。需要重新生成一次。
      

  4.   

    在后台中向datagrid中插入textbox的操作要放在在page_load中才可以,要不不能用findconrol找到的