Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Update of Datagrid after delete

Reply
Thread Tools

Update of Datagrid after delete

 
 
=?Utf-8?B?S2FzaGlmIE1laG1vb2Q=?=
Guest
Posts: n/a
 
      06-03-2004
Greeting

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)

conFRSH.Open(
cmdClientTypes.ExecuteNonQuery(
conFRSH.Close(

dgClientTypes.DataSource = DsClientTypes
dgClientTypes.DataBind(
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
SqlDataAdapter1.Fill(DsClientTypes1
If Not IsPostBack The
dgClientTypes.DataBind(
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

Regards
 
Reply With Quote
 
 
 
 
=?Utf-8?B?bmF0WA==?=
Guest
Posts: n/a
 
      06-03-2004
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
I.E

Protected Sub dgClientTypes_Fill(
'Put code to fill the dataset using a dataadapte
Dim oDa as New SqlClient.SqlDataAdapte
...
oDa.Fill(DsClientTypes1
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 =
dgClientTypes.DataBind(
End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to update datagrid after update =?Utf-8?B?TWljaGFlbA==?= ASP .Net 1 03-17-2006 07:24 PM
Edit, Update, Delete DataGrid Problem jinhy82 ASP .Net 0 06-06-2005 10:38 AM
Bound DataGrid Wizard with built in Update/Delete/Insert? Mark ASP .Net 2 11-24-2004 12:02 PM
Delete key doesn't delete when datagrid is bound to a disconnected table Fred Zolar ASP .Net Datagrid Control 0 04-01-2004 07:47 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments