Hi All,
I have dataGrid and as its datasource is dataset. When I edit ne row, I have
to click on the next (or previous) row to this (new)row will be add into the
dataset. That is problem , if user add new row and immediate save the
dataset. in this scenario the new row don't add into the dataset.
Any sugestion?
Thanx
Honza 15 5340
Jan,
One of the most asked questions in relation to ADONET.
The data in the datagrid is pushed down to the datasource after a rowchange.
You can force that with (here showed for the first table)
BindingContext(ds.Tables[0]).EndCurrentEdit();
I hope this helps
Cor
Dear Cor,
thank you for you heko. But I didn't follow your think. I don't know How can
I use this method:
EndCurrentEdit();
Thank you again Cor,
Jan
"Cor Ligthert" wrote: Jan,
One of the most asked questions in relation to ADONET.
The data in the datagrid is pushed down to the datasource after a rowchange. You can force that with (here showed for the first table)
BindingContext(ds.Tables[0]).EndCurrentEdit();
I hope this helps
Cor
Jan,
What is the problem with it, you need to set that before the place you want
to get information from a datarow according the last changed datagridrow
without that you did a row change in the datagrid.
BindingContext(ds.Tables[0]).EndCurrentEdit();
Where I wrote that ds.Table[0] is in this case the first table. However can
be of course any table or dataview.
What is the problem,
I don't see it.
Cor
Cor,
when i used this
BindingContext(ds.Tables[0]).EndCurrentEdit();
I received error:
error CS0118: 'System.Windows.Forms.Control.BindingContext' denotes a
'property' where a 'method' was expected
So I tried to use this:
BindingContext[ds.Tables[0]].EndCurrentEdit();
it's look much better, because compiler doesn't show any error, but new row
doesn't save into dataset.....
I know, mistakes is on my side, but i don' t know where.....
Thanks
Jan
Jan,
BindingContext[ds.Tables[0]].EndCurrentEdit();
This is not the first time I make this mistake and forget that it is a
collection of bindingcontextes.
Sorry
Cor BindingContext[ds.Tables[0]].EndCurrentEdit();
This does not work for me either. I think the DataBinding must have to be
explicitly set somewhere, but I don't see where. Ideas?
Jan,
When the user does not click on the little pencil to confirm the update,
than it will never be done. I was involved in a long thread in another
newsgroup because that was not done.
Cor
Cor: I wonder if you are thinking of web forns, not windows forms.
I had better luck using the name of the table "data_path." :
BindingContext[dsPaths,"data_paths"].EndCurrentEdit() ;
It saved the row, but did not capture the data from the last cell. It worked
better when I forced the column to change:
dgPaths.CurrentCell = new DataGridCell(dgPaths.CurrentCell.RowNumber,
1-dgPaths.CurrentCell.ColumnNumber);
BindingContext[dsPaths,"data_paths"].EndCurrentEdit() ;
This is impossibly clumsy. The language designers must have had some
non-hack solution in mind to such an ordinary situation.
Hi,
You are on the right track, but instead of moving grid focus to another
cell, I'd suggest that you use the grid's EndEdit() method.
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com... Cor: I wonder if you are thinking of web forns, not windows forms.
I had better luck using the name of the table "data_path." :
BindingContext[dsPaths,"data_paths"].EndCurrentEdit() ;
It saved the row, but did not capture the data from the last cell. It worked better when I forced the column to change:
dgPaths.CurrentCell = new DataGridCell(dgPaths.CurrentCell.RowNumber, 1-dgPaths.CurrentCell.ColumnNumber); BindingContext[dsPaths,"data_paths"].EndCurrentEdit() ;
This is impossibly clumsy. The language designers must have had some non-hack solution in mind to such an ordinary situation.
> You are on the right track, but instead of moving grid focus to another cell, I'd suggest that you use the grid's EndEdit() method.
Well, you know, I thought of that, but
dgPaths.EndEidt() ;
gives a compile error of
"Windows.Systems.Forms.DataGrid.EndEdit is inaccessible due to its
protection level."
despite the fact that EndEdit is offered as an option by Intellisense.
Derive a control from the datagrid and expose this protected method through
a public helper method.
The helper method can determine the current row and current column style
before calling the protected EndEdit().
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com... You are on the right track, but instead of moving grid focus to another cell, I'd suggest that you use the grid's EndEdit() method.
Well, you know, I thought of that, but
dgPaths.EndEidt() ;
gives a compile error of "Windows.Systems.Forms.DataGrid.EndEdit is inaccessible due to its protection level."
despite the fact that EndEdit is offered as an option by Intellisense.
> Derive a control from the datagrid and expose this protected method through a public helper method. The helper method can determine the current row and current column style before calling the protected EndEdit().
The method using the column style and row is not protected, so helper is not
required, and, I think won't work for other reasons. I wrote this:
private void AcceptText(){
DataGridColumnStyle dgc =
dgPaths.TableStyles[0].GridColumnStyles[dgPaths.CurrentCell.ColumnNumber] ;
dgPaths.EndEdit(dgc,dgPaths.CurrentCell.RowNumber, false ) ;
BindingContext[dsPaths,"data_paths"].EndCurrentEdit() ;
}
It seems to do the trick. On to the next problem.
That's actually the right way of committing editing in progress.
BTW, I was really surprised to know there is another protected overload of
EndEdit().
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"eye5600" <ey*****@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com... Derive a control from the datagrid and expose this protected method through a public helper method. The helper method can determine the current row and current column style before calling the protected EndEdit().
The method using the column style and row is not protected, so helper is not required, and, I think won't work for other reasons. I wrote this:
private void AcceptText(){ DataGridColumnStyle dgc = dgPaths.TableStyles[0].GridColumnStyles[dgPaths.CurrentCell.ColumnNumber] ; dgPaths.EndEdit(dgc,dgPaths.CurrentCell.RowNumber, false ) ; BindingContext[dsPaths,"data_paths"].EndCurrentEdit() ; }
It seems to do the trick. On to the next problem. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael Schindler |
last post by:
ROW Accountnr Amount
1 1001 12.00
2 1001 -12.00
3 1002 40.00
4 1002 -12.00
5 1002 ...
|
by: David |
last post by:
In C#, when I create a DataGrid, use a SetDataBinding to set the data
to the dataset, then update the datagrid, is there a way to get a
dataset object back from the DataGrid control so that I can...
|
by: Phil Snijder |
last post by:
Hi there,
I have a form with a Datagrid on it; Datagrid is bound to an untyped dataset.
When I fill the dataset (with an oleDBDataAdapter), the data is not diplayed directly in the grid;
I have...
|
by: Fernando |
last post by:
I will explain the problem that i have with as much detail as i can.
I have an application developed using C# & SQL 2000. I am using a relational
database scheme.
The problem is present in this...
|
by: Jan Schustr |
last post by:
I have dataGrid and as datasource is dataSet.Table .
In my app i set datasource to dataset.tables , in this moment is dataset
empty. Then user click on the button, run another (long-during) thread,...
|
by: Marty |
last post by:
In winforms, I can bind a datagrid to a dataset. When the user wants to
submit changes, it's easy to see what has changed with the DataSet
"GetChanges" method.
In ASP.Net, I can create the...
|
by: Mat |
last post by:
I have typed dataset in applications, which contains table A(ID,name) ,
B(ID,A1, B1,B2)
Table B has columns A1 as foreign key ,primary key of table A
i want to bind dataset or dataview to...
|
by: Maria Anthonsen |
last post by:
I have filled a datagrid with data from a dataset. The dataset was filled
with a dataadapter - and I used the wizard to create insert, update, delete
commands.
I would like to prevent the user...
|
by: John |
last post by:
I use VB .NET 2003 and here's the code:
MyDatagrid.datasource = MyDatset.Tables("MyTable").DefaultView
It seems that if I enter new values into the datagrid, the dataset gets
updated. My...
|
by: marcmc |
last post by:
My dataset is not updating my database after the user modifies the datagrid.
I populate my data with the load sub below.
In the Save Sub (below), I have generated my DataSet 'dataSet11' from my...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |