473,698 Members | 2,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3797
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 CurrentItemChan ged event:

"BindingSource. CurrentItemChan ged 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.RowC hanged 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.R owValidated 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.RowStat e property for any value
other than
DataRowState.Un changed and DataRowState.De tached.

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

--
Dave Sexton

<se*****@gmail. comwrote in message
news:11******** *************@7 3g2000cwn.googl egroups.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
4042
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 Class ExtendedSearchFieldValueColumnStyle Inherits DataGridTextBoxColumn Public WithEvents ColumnComboBox As ComboBox Public WithEvents ColumnTextBox As TextBox
0
261
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 of making the row editable for user, PageIndexChanged event is fired and grid's current page is changed. When I click on next/previous page my current page is not chaning. Can any body help me what to do. My complete code is as under Private Sub...
0
1177
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? If i turn this off then i need to support building the datagrid because the datagrid is not persistant. Right?
4
1792
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 when the Edit button is pressed? Thank you, Stephan.
3
4094
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 period of time. I need to deliver this code tomorrow morning to my boss! Thanks a lot Mike
0
1341
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 as expected but when user clicks the Edit link, the cells do NOT turn into editable text boxes. I actually need only the first column to be editable but any ideas on getting the whole row editable would help at first. Apologies for the amount of...
7
2296
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 page load. In my EditCommand event handler I set the editItemindex. All good. Except, the user needs to click twice to get the DataGrid to become editable. It's obvious to me (perhaps worngly) that ASP.NET is storing the data
6
1609
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 only want records from the table where "State= 'CA'" are to be displayed, but where the user can still edit/add/delete records. The only examples I have found utilizes DataViews, which apparently are not editable. Can someone point me to the...
3
2122
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
8674
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
8603
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
9023
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
8893
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
7721
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3045
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
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1999
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.