您好我将要通过在动态填充的Gridview上创建的文本框更新一些数据,但遗憾的是当我点击更新按钮时,我的代码无法读取我在这些文本框上输入的内容。继承我的代码:
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()
答案 0 :(得分:0)
仅在页面未回发时检查以绑定gridview。