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
511 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now