I want to update the AResult with click approve or reject button.
In my aspx page, here my code,
<asp:ButtonField ButtonType="Button" CommandName="Approve" Text="Approve" runat="server" />
<asp:ButtonField ButtonType="Button" CommandName="Reject" Text="Reject" runat="server" />
My aspx.vb code,
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles GridView1.RowCommand
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("dbconnection").ConnectionString)
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
con.Open()
If e.CommandName.CompareTo("Approve") = 0 OrElse _
e.CommandName.CompareTo("Reject") = 0 Then
' The Approve or Reject Button has been clicked
' Determine the ID of the appointment whose result was adjusted
Dim AID As Integer = Convert.ToInt32(_GridView1.DataKeys(Convert.ToInt32(e.CommandArgument)).Value)
Dim cmd As New SqlCommand
cmd.Connection = con
If e.CommandName.CompareTo("Approve") = 0 Then
cmd = New SqlCommand("UPDATE [Appointment] SET AResulT = N'Approve'", con)
ElseIf e.CommandName.CompareTo("Reject") = 0 Then
cmd = New SqlCommand("UPDATE [Appointment] SET AResult = N'Reject'", con)
End If
cmd.ExecuteNonQuery()
Response.Redirect("Waiting List")
con.Close()
End If
End Sub
When i click on approve button, it will update my whole appointment's result with approve. Can someone teach me how to detect the row when i click the button?