Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / June 2004

Tip: Looking for answers? Try searching our database.

Refresh datagrid after SQL direct update

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Wagoner - 28 Jun 2004 14:44 GMT
I have a DataGrid displaying a summary of data from multiple SQL tables.
I am using the DataGrid UpdateCommand event handler to call a sub that
updates a single table record using the sqlcommand.executenonquery
command. After the sub, I tried to have the DataGrid refresh and display
the updated data. However, the this does not happen until a refresh, or
until I go to edit the record. I thought the SQLDataAdapter1.Fill action
would refresh the dataset with the new data.

Any help is appreciated!

Here is the relevant code (updateRecord is the sub that updates the sql
table directly):

Private Sub DataGrid1_UpdateCommand(ByVal source As System.Object, ByVal
e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.UpdateCommand

   updateRecord(value1, value2, value3)

   SqlDataAdapter1.Fill(DataSet11)
   DataGrid1.DataBind()
End Sub
Dave Wagoner - 28 Jun 2004 15:48 GMT
To answer my own question, the thread at
http://www.dotnet247.com/247reference/msgs/30/152582.aspx helped me a ton.

My problem was that I was not clearing the dataset prior to the
fill/bind. Working code:

Private Sub DataGrid1_UpdateCommand(ByVal source As System.Object, ByVal
 e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
 DataGrid1.UpdateCommand

    updateRecord(value1, value2, value3)
    DataSet11.Clear()
    SqlDataAdapter1.Fill(DataSet11)
    DataGrid1.DataBind()
 End Sub

> I have a DataGrid displaying a summary of data from multiple SQL tables.
> I am using the DataGrid UpdateCommand event handler to call a sub that
[quoted text clipped - 18 lines]
>    DataGrid1.DataBind()
> End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.