简体   繁体   English

如何在vb.net的动态gridview上找到创建的文本框?

[英]how to find the created textbox on a dynamic gridview in vb.net?

Hi I'm about to update some data through a textbox created on a dynamic filled Gridview but sadly when I click the update button, my code cannot read what I have inputed on those textboxes. 嗨,我要通过在动态填充的Gridview上创建的文本框更新一些数据,但是可悲的是,当我单击更新按钮时,我的代码无法读取我在这些文本框上输入的内容。 Heres my code: 这是我的代码:

sqlcon = New SqlConnection(conString)

        Dim id = GridAnswers.DataKeys(e.RowIndex).Value
        Dim row As GridViewRow = TryCast(GridAnswers.Rows(e.RowIndex), GridViewRow)
        Dim ChoiceDescription As TextBox = TryCast(row.FindControl("ChoiceDescription"), TextBox)
        Dim Rating As TextBox = TryCast(row.FindControl("Rating"), TextBox)
        DropDownList)
        Using sqlcon As New SqlConnection
        Dim sql As String = "UPDATE CS_RefQuestionChoice SET ChoiceDescription=@choice, RatingID=@ratingid WHERE ChoiceID=@qid"
        Using cmd As New SqlCommand(sql, sqlcon)
            cmd.Parameters.AddWithValue("@choice", ChoiceDescription.Text)
            cmd.Parameters.AddWithValue("@ratingid", Rating.Text)
            cmd.Parameters.AddWithValue("@id", id)
            sqlcon.Open()
            cmd.ExecuteNonQuery()
            sqlcon.Close()
        End Using
         End Using
        GridAnswers.EditIndex = -1
        gridbind()

仅在未回发页面的情况下,检查以绑定gridview。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM