473,398 Members | 2,380 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,398 software developers and data experts.

Editable Datagrid C# Windows Application Help

I want to build a windows application that has a datagrid filled with
data. When a person modifies information on a single cell, it updates
the database without the user having to click on a save button.

Any ideas on how I can accomplish this?

Thanks,

Sean

Dec 1 '06 #1
1 3775
Hi Sean,

You could handle the appropriate changed event of the data source. In the
2.0 framework you could use a BindingSource component to wrap your data
source and handle the CurrentItemChanged event:

"BindingSource.CurrentItemChanged Event"
http://msdn2.microsoft.com/en-us/lib...emchanged.aspx

If you're binding directly to a DataTable or DataSet you can handle the
RowChanged event on the DataTable to which the grid is bound:

"DataTable.RowChanged Event"
http://msdn2.microsoft.com/en-us/lib...owchanged.aspx

If you're binding to a custom object or binding list you can implement your
own property changed event (although you can still use a BindingSource in
the 2.0 framework)

(Note: If you're using the 2.0 framework use the DataGridView control
instead of DataGrid, which is included in the VS 2005 Toolbox instead of
DataGrid anyway)

I recommend that you don't do this for a single cell, however. Instead,
think about updating the database after the current row loses focus and has
been validated. Also, the entire process is much easier using a
DataGridView. Simply handle the RowValidated event and perform the database
update there:

"DataGridView.RowValidated Event"
http://msdn2.microsoft.com/en-us/lib...ed(VS.80).aspx

You can tell whether a row has changes after it loses focus easily if you're
using a DataSet by checking the DataRow.RowState property for any value
other than
DataRowState.Unchanged and DataRowState.Detached.

"DataRow.RowState Property"
http://msdn2.microsoft.com/en-us/lib....rowstate.aspx

--
Dave Sexton

<se*****@gmail.comwrote in message
news:11*********************@73g2000cwn.googlegrou ps.com...
>I want to build a windows application that has a datagrid filled with
data. When a person modifies information on a single cell, it updates
the database without the user having to click on a save button.

Any ideas on how I can accomplish this?

Thanks,

Sean

Dec 2 '06 #2

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

Similar topics

0
by: Faith | last post by:
I found code on www.codeproject.com. Here is a sample it is called DataGridColumnDropDown. I modified it to use the text box when I wanted it to depended on a certain search criteria. Public...
0
by: Shail | last post by:
Hello every one I am using editable datagrid in my application. I set grid's allowpaging property to true. My application is not working properly. When I click on 'Edit' to modify any row, instead...
0
by: Andla Rand | last post by:
Hi, Could you help me to understand how datagrid works. I'm trying to make a datagrid editable. Now most of the tutorials I read says that i should turn the Enable ViewState off. Why is that? ...
4
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns...
3
by: Mike | last post by:
Hi, I need to code an editable DataGrid without any fancy stuff. I am new to ASP.NET and I was wondering whether there are some resources that allow to build this editable grid in a very short...
0
by: DaveR | last post by:
I have a webform with a two-column datagrid based on an Arraylist. The Arraylist draws the data for the two columns from two different tables in an SQL database. The data is displayed in datagrid...
7
by: Diane | last post by:
Hi- I've been struggling with this problem and none of the fixes posted seem to help out at all. Yet, it seems like such a simple problem... I have a DataGrid, and load it up with data on...
6
by: Richard L Rosenheim | last post by:
I'm sure it can be done, I haven't been able to find the right article yet. I want to be able to filter the records that the datagrid displays, but still have an editable datagrid. That is, I...
3
by: Nina | last post by:
Hi there, Is there anyone knows how to make windows form datagrid that is bound to an array editable? How to catch when a cell has been edited? Thank you for your help. Nina
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.