David Glover
asked on
After using a command button on a gridview to activate a stored procedure, how do I 'refresh' the row in the gridview?
I am using the code below to execute a stored procedure. The procedure results in a change in value on the displayed gridview row but the gridview doesn't show this change until I reload the page manually. How do I make the row refresh after clicking the command button?
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
If e.CommandName = "SetMessagePreference" Then
Dim sConnStr As String = SqlDataSource1.ConnectionString
Dim cnBKTest As New SqlConnection(sConnStr)
Dim cmdTest As New SqlCommand("FGContactDetailsMessagePreference", cnBKTest)
cmdTest.CommandType = Data.CommandType.StoredProcedure
cmdTest.Parameters.Add(New SqlParameter("@ContractID", Data.SqlDbType.VarChar, 10))
cmdTest.Parameters("@ContractID").Value = e.CommandArgument
cmdTest.Parameters.Add(New SqlParameter("@MessagePreferenceID", Data.SqlDbType.VarChar, 10))
cmdTest.Parameters("@MessagePreferenceID").Value = 2
cnBKTest.Open()
cmdTest.ExecuteNonQuery()
cnBKTest.Close()
End If
End Sub
You have to Rebind the Grid
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks John, that did the trick.