468,771 Members | 1,878 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

Update of Datagrid after delete


I am using the following code to delete a row from a datagrid
Private Sub dgClientTypes_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles dgClientTypes.DeleteComman

cmdClientTypes.CommandText = "Delete from tbClientTypes where (ClientTypeID = @ClientTypeID)

cmdClientTypes.Parameters.Add("@ClientTypeID", SqlDbType.SmallInt
cmdClientTypes.Parameters("@ClientTypeID").Value = dgClientTypes.DataKeys(CInt(e.Item.ItemIndex)


dgClientTypes.DataSource = DsClientTypes
End Su

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
'Put user code to initialize the page her
If Not IsPostBack The
End I

End Su

The problem is that the page is not showing updated values after the change. Help would be appreciated. Thanks in advance

Nov 18 '05 #1
1 1170
You're executing your query to delete the records but not refreshing you DsClientTypes1 dataset.

I usually code two methods for my dataset/datagrid DataGrid_Fill and DataGrid_Bind. Call DataGrid_Fill after you make modifications to the database and want to refresh the dataset/datatable for the grid. Call DataGrid_Bind when you just want to add a RowSelect for sorting/filtering/etc. on a dataview

Protected Sub dgClientTypes_Fill(
'Put code to fill the dataset using a dataadapte
Dim oDa as New SqlClient.SqlDataAdapte
Session("vClientTypes") = New DataView(DsClientTypes1

End Su

Protected Sub dgClientTypes_Bind(
'Put code to bind up the datagri
Dim v As DataView = DirectCast(Session("vClientTypes"),dataview
'Do any RowFilter her

dgClientTypes.DataSource =
End Sub
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Wing | last post: by
3 posts views Thread by Kevin Pedersen | last post: by
1 post views Thread by BW | last post: by
25 posts views Thread by Neo Geshel | last post: by
4 posts views Thread by Jonathan Upright | last post: by
4 posts views Thread by drakuu | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.