473,395 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Update of Datagrid after delete

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
Nov 18 '05 #1
1 1286
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
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wing | last post by:
Hi all, I have created 2 tables in sql database and join these 2 tables before assign the result to the dataset, and display the result in datagrid. Everything is fine up to this point. The...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
1
by: BW | last post by:
Hello, I am attempting to to take edited values from a datagrid control and update the underlying database. Problem is that some of the edited values don quite seem to make it to my update sub....
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
4
by: Jonathan Upright | last post by:
Greetings to anyone who can help: I'm using WebMatrix to make ASP.NET pages, and I chose the "Editable DataGrid" at the project selector screen. As you may know, it defaults to the Microsoft...
1
by: mivey4 | last post by:
Okay, The problem is that I have an Access Database that has the following fields: EmpID - Autonumber (PrimaryKey) AccountID - Text IssueReported - Memo DateOpened ...
5
by: Earl | last post by:
I want to fire a database update off of a single change to a single cell in the datagrid. This apparently cannot be done using keypress, keyup, keydown, etc. I've read George Shepard's FAQ and...
4
by: drakuu | last post by:
Hello there, I have DataGrid with some records and I would like to edit it right in the datagrid using the built in commands. I can't figure out a way to pass to the SQL query the record ID...
0
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid...
2
tjc0ol
by: tjc0ol | last post by:
Hi guys, Im just wondering that I cannot update my database throught datagrid datalist control, and the only thing works is that I can delete, cancel, edit but when I clicked update link...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.