deletecommand via sqldataadapter

P

peg

OK here is my problem, i have a datagrid based on a Dataset/SQLDataAdapter
(created based on stored procs already in place)

When i click on the Delete button (built in template delete) in the datagrid
it does delete the record but the datagrid doesn't refresh even tho there is
a DataBind being done. After i click on delete if i refresh the page the
record disappears - i'm at a loss for why this is doing this!

below is my code - thanks in advance!!

Private Sub ClientGrid_DeleteCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
ClientGrid.DeleteCommand

Dim key As String = ClientGrid.DataKeys(e.Item.ItemIndex).ToString()
SqlDataAdapter1.DeleteCommand.Parameters("@ClientID").Value =
Convert.ToInt16(key)

Try
If SqlConnection1.State = ConnectionState.Closed Then
SqlConnection1.Open()
End If
SqlDataAdapter1.DeleteCommand.ExecuteNonQuery()
Catch Exp As SqlException
lblMessages.Text = "Error"
End Try

SqlDataAdapter1.Fill(DataSet11)
ClientGrid.DataBind()
SqlConnection1.Close()

End Sub
 
P

peg

The Datasource is set in the datagrids properties, not set during
runtime.... hope that is what you were looking for.

DataKeyField = ClientID
DataMember=QC_ListClients
DataSource = DataSet11
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top