Solved

After using a command button on a gridview to activate a stored procedure, how do I 'refresh' the row in the gridview?

Posted on 2008-10-13
3
513 Views
Last Modified: 2013-11-07
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

Open in new window

0
Comment
Question by:dgloveruk
  • 2
3 Comments
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22701859
You have to Rebind the Grid
0
 
LVL 4

Accepted Solution

by:
sijishJohn earned 250 total points
ID: 22701873
GridView1.DataSource = <Your Data source>
GridView1.DataBind()
0
 

Author Closing Comment

by:dgloveruk
ID: 31406252
Thanks John, that did the trick.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question