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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 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

20 Experts available now in Live!

Get 1:1 Help Now