IdCount = GridViewExe.DataKeys.Item(e.RowIndex).Value.ToString()
Select Case result
Case MsgBoxResult.Yes
Dim txtQuestion As TextBox = CType(GridViewExe.Rows(e.RowIndex).FindControl("txtEditQuestion"), TextBox)
Dim txtSentence As TextBox = CType(GridViewExe.Rows(e.RowIndex).FindControl("txtEditSentence"), TextBox)
Dim txtChoise1 As TextBox = CType(GridViewExe.Rows(e.RowIndex).FindControl("txtEditChoise1"), TextBox)
Dim txtChoise2 As TextBox = CType(GridViewExe.Rows(e.RowIndex).FindControl("txtEditChoise2"), TextBox)
Dim txtAnswer As TextBox = CType(GridViewExe.Rows(e.RowIndex).FindControl("txtEditAnswer"), TextBox)
Dim txtChoise3 As TextBox = CType(GridViewExe.Rows(e.RowIndex).FindControl("txtEditChoise3"), TextBox)
Dim txtChoise4 As TextBox = CType(GridViewExe.Rows(e.RowIndex).FindControl("txtEditChoise4"), TextBox)
conn.Open()
Dim sqlUpdate As String = "update Exercises set Question='" + txtQuestion.Text + "' ,Sentence='" + txtSentence.Text + "' ,AnsChoise1='" + txtChoise1.Text + "' ,AnsChoise2='" + txtChoise2.Text + "' ,AnsChoise3='" + txtChoise3.Text + "' ,AnsChoise4='" + txtChoise4.Text + "' ,Answer='" + txtAnswer.Text + "' where Id_Question ='" + IdCount + "'"
Dim sqlComUpdateExe As New SqlCommand(sqlUpdate, conn)
sqlComUpdateExe.ExecuteNonQuery()
conn.Close()
Tag : .NET, Web (ASP.NET), VB.NET, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)