473,767 Members | 2,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating datagrid

hi,
i have an editable datagrid. how can i update the
database, When the user completes entering data for a row.
i.e., data should be updated whenever user completes
entering a row.

Thanks in advance.

Nov 15 '05 #1
2 5609
Nanda,

In this case, you will have to hook into the grid and catch when the row
changes. When this happens, you will have to access the data adapter that
created the data set that the grid bound to, and pass the data set to the
adapter through the Update method.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Nanda" <cs******@yahoo .co.in> wrote in message
news:0a******** *************** *****@phx.gbl.. .
hi,
i have an editable datagrid. how can i update the
database, When the user completes entering data for a row.
i.e., data should be updated whenever user completes
entering a row.

Thanks in advance.

Nov 15 '05 #2
To add some details:

OnCurrentCellCh anged should be overridden to determine when the user is
moved to the next row.

Then the row state should be analyzed, and if the underlying data row has
been changed, changes should be propagated to the database.

Current underlying data row can be obtained like this:

CurrencyManager cm = (CurrencyManage r)grid.BindingC ontext[grid.DataSource ,
grid.DataMember];

DataView view = (DataView)cm.Li st;

DataRow currentRow = view[grid.CurrentCel l.RowNumber].Row;

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Unit Testing and Integration Environment
http://x-unity.miik.com.ua
Deliver reliable .NET software

"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote
in message news:en******** *****@tk2msftng p13.phx.gbl...
Nanda,

In this case, you will have to hook into the grid and catch when the row changes. When this happens, you will have to access the data adapter that
created the data set that the grid bound to, and pass the data set to the
adapter through the Update method.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Nanda" <cs******@yahoo .co.in> wrote in message
news:0a******** *************** *****@phx.gbl.. .
hi,
i have an editable datagrid. how can i update the
database, When the user completes entering data for a row.
i.e., data should be updated whenever user completes
entering a row.

Thanks in advance.



Nov 15 '05 #3

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

Similar topics

0
1303
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to the database? I've used the following code for the DataGird1_UpdateCommand Option1
1
1241
by: Patrick Delifer | last post by:
HI, I am trying to update a DataGrid where I want to rebind just the row that was updated. Here's the situation: 1) Updating is not a problem, it works fine. 2) I am not using ItemCommand (edit, delete, etc) 3) the button that issues the update/rebind is outside the datagrid, on the web form. Till now I have been issuing a full DataBind for the entire DG, that I read
5
2038
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated one row, all of them were updated so i immediatelly figured out that i have to include the id of every entry in the update statement. This is where the problem is raised. My database is an Access database. The table i am updating contains a Date...
0
1639
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables have a FK relationship on CAR_ID so the oracledataadapter1 select statement(CommandText) is: select car_master.car_id, car_master.year,car_master.vehicle,car_detail.car_id AS EXPR1,
10
5681
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1) DsStudentCourse1.AcceptChanges() i'm also wondering because w/ out AcceptChanges the data is still save into the database and it is now faster.
0
1062
by: Mike P | last post by:
I'm updating a datagrid which works fine, but after updating the datagrid does not return to 'view' status, remaining in 'edit' status. Has anybody else had this problem? Thanks, Mike
2
1675
by: Greg | last post by:
I'm using the Framework 1.1, so I don't have access to the new DataGridView object. What I'm wondering is, is there a really simple way to bind a plain datagrid to a database in such a way that changes made to cells in the datagrid call an update on the corresoonding data within a database? I've looked in vain for a really simple way to do this with minimal coding, but I'm coming to the conclusion that I will have to trap the events of...
2
1329
by: marcmc | last post by:
Hey, I have never used a datagrid/dataset/adaptor/table method for updating data, I have always used direct updates to the database so ADO is quite new to me. I have a datagrid and I change a value in one of the fields. I hit save and the following code runs... Dim da As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("Select * from MISRE_Threshold", cn) da.Update(dsThreshold, "MISRE_Threshold")
0
1471
by: Chet | last post by:
I have a Datagrid that is bound to a Datatable at runtime. I allow the user to select a number of rows using the mouse and then click a button that says "check selected rows", which then cycles through the selected rows and sets a check box field in the datagrid (and thus the databound datatable) to checked/true. It works like this: Dim cel As DataGridViewCheckBoxCell For Each row In DataGrid.SelectedRows cel = row.Cells(0) cel.Value =...
2
3321
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the CurrentChanged event of the BindingSource of the combobox to update the textbox. When selecting an item in the combobox or when selecting a row in the grid, it is updating the textbox correctly. The problem is when I apply a filter in the grid, and then...
0
9571
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9405
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10169
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10013
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5424
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3930
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.