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