Hallo!
I have filled a datagrid with data from a database. I would like to edit
the data in the datagrid and save it back to the database. My problem is
that I don't really know how to capture the event of the cell that I am
editing. The code below works but I would like to edit the data in a cell
and then for example click a button and save it.
Here is little of my code :
void Button5Click(ob ject sender, System.EventArg s e)
{
int colNr = dataGrid4.Curre ntCell.ColumnNu mber;
int rowNr = dataGrid4.Curre ntCell.RowNumbe r;
string s = dataGrid4.Curre ntCell.ToString ();
string currentCellData = null;
EventHandler eh = null;
currentCellData = textBox2.Text;
DataGridCell dc = new DataGridCell(ro wNr, colNr);
dataGrid4[dc] = currentCellData ;
} 3 1581
To get the value directly from the cell, try code like:
int colNr = dataGrid4.Curre ntCell.ColumnNu mber;
int rowNr = dataGrid4.Curre ntCell.RowNumbe r;
object cellValue = dataGrid4[rowNr, colNr];
=============== ==
Clay Burch, .NET MVP
Visit www.syncfusion.com for the coolest tools
"tigerbalm via DotNetMonster.c om" <fo***@nospam.D otNetMonster.co m> wrote in
message news:79******** *************** *******@DotNetM onster.com... Hallo!
I have filled a datagrid with data from a database. I would like to edit the data in the datagrid and save it back to the database. My problem is that I don't really know how to capture the event of the cell that I am editing. The code below works but I would like to edit the data in a cell and then for example click a button and save it.
Here is little of my code :
void Button5Click(ob ject sender, System.EventArg s e) { int colNr = dataGrid4.Curre ntCell.ColumnNu mber; int rowNr = dataGrid4.Curre ntCell.RowNumbe r; string s = dataGrid4.Curre ntCell.ToString (); string currentCellData = null; EventHandler eh = null; currentCellData = textBox2.Text; DataGridCell dc = new DataGridCell(ro wNr, colNr); dataGrid4[dc] = currentCellData ;
}
Try This Out
dataGrid4.Curre ntCellChanged += new EventHandler(Gr id_CurCellChang e);
private void Grid_CurCellCha nge(object sender, EventArgs e)
{
object currentCell = dataGrid4[dataGrid4.Curre ntCell.RowNumbe r,
dataGrid4.Curre ntCell.ColumnNu mber]
}
Regards,
Dhanushka
"ClayB [Syncfusion]" <cl***@syncfusi on.com> wrote in message
news:eP******** ******@TK2MSFTN GP10.phx.gbl... To get the value directly from the cell, try code like:
int colNr = dataGrid4.Curre ntCell.ColumnNu mber; int rowNr = dataGrid4.Curre ntCell.RowNumbe r; object cellValue = dataGrid4[rowNr, colNr];
=============== == Clay Burch, .NET MVP
Visit www.syncfusion.com for the coolest tools
"tigerbalm via DotNetMonster.c om" <fo***@nospam.D otNetMonster.co m> wrote
in message news:79******** *************** *******@DotNetM onster.com... Hallo!
I have filled a datagrid with data from a database. I would like to edit the data in the datagrid and save it back to the database. My problem is that I don't really know how to capture the event of the cell that I am editing. The code below works but I would like to edit the data in a
cell and then for example click a button and save it.
Here is little of my code :
void Button5Click(ob ject sender, System.EventArg s e) { int colNr = dataGrid4.Curre ntCell.ColumnNu mber; int rowNr = dataGrid4.Curre ntCell.RowNumbe r; string s = dataGrid4.Curre ntCell.ToString (); string currentCellData = null; EventHandler eh = null; currentCellData = textBox2.Text; DataGridCell dc = new DataGridCell(ro wNr, colNr); dataGrid4[dc] = currentCellData ;
}
thanks guys, the code works. But I also want to send the updated data back
to the database. I programmed in Java before and there it was easy to
browse through the cells and send the updates back to the database. How do
I do it in C#? I know I have to use the dataadapters updatecommand. Please
tell me how to do it.
--
Message posted via DotNetMonster.c om http://www.dotnetmonster.com/Uwe/For...sharp/200505/1 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Swaroop |
last post by:
Hi,
I am using a Datagrid to populate the details given by a user in the footer
of the datagrid.i am using an object array to populate the datagrid(a sample
project so not using a database to populate from).Now when i am using the
edit function of the datagrid i am not able edit(i.e i am not able to view
the data in textboxes to edit).it gives me the same old row as usual.when i
am checking to display the index,it shows me the index of...
|
by: TT (Tom Tempelaere) |
last post by:
Hi,
Suppose there is a DataGrid on a form bound to a DataTable. When a user is
editing a cell without leaving the cell, and then closes the form, the value
is not updated to the underlying data source.
How can I accomplish this?
Thanks,
--
|
by: Dave |
last post by:
Tried posting in the Winform Forum without much luck, so posting here...
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is after the newly
added row without getting bizarre results.
I have added the full code for the test below. Create a project drop
in the code and run. There is nothing crazy about the code. I used
the designer to add the dataset and to do the...
|
by: Islamegy |
last post by:
When i press btn_save all changed rows in my grid get saved except the last
editing row...
I want my btn_Save to end editing in the datagrid.. so if user didn't press
"enter" after editing last cell of the current row, I could force this row
to be saved in the datasource.
help plz
|
by: Blake Versiga |
last post by:
When editing a datagrid (C#)
I need to know if the user changed the value of cell AND what the previous
value was.
Is this possible? If so how do I get the previous value or at least if the
cell has changed?
TIA
Blake
| |
by: Raterus |
last post by:
Here is my only problem with using the datagrid to edit data. Say I have a
moderate sized table, with about 15 columns. I want to allow a user to be
able to edit most all of these fields, except for say a primary key. If I
use the edit capabilities of the datagrid, I'll end up with a grid about 15
columns wide, which most certainly won't fit on one page (scrolling
left/right in a webpage a big thing I try to avoid).
What I'd like is...
|
by: tshad |
last post by:
Is there a way to use your own image in place of the automatic one that ASP
uses when doing editing in your DataGrid pages?
We already have a style of button we are using and would like to be
consistant.
Thanks,
Tom.
|
by: jason |
last post by:
hi,
I have a datagrid in my input form. Using datagrid inplace editing to save
data (chinese characters) entered by user.
It works as expected on my test record.
But, when i started to enter new record, the datagrid textbox.text shows
"??" instead of the chinese character.
|
by: prerak_v_shah |
last post by:
Hi,
Friends, I have been developing datagrid program in .Net 1.1 and having VB.Net as a programming language.
I have created a datagrid which is bound to a datatable as its datasource. It also shows two columns and both are having comboboxes as its selection control. Data grid is editable and it allows Add, Delete, Modify functionalities.
I have also created event handler to trap any rowchanges (RowChanged event) in the grid. Here I...
|
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,...
|
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...
| |
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...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |