Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 





Save record in datagrid while still editing (Wednesday, September 15, 2004)



Found the following interesting discussion in the Newsgroups:

save record in datagrid while still editing
by:jaYPee

i'm wondering how can i update the current record in datagrid while
still editing the record. cause i have a checkbox in my datagrid and i
want to save the record before changing the value of this checkbox to
true to enforce referential integrity. i don't have problem changing
the checkbox to true if the record/row in my datagrid is already save.
the problem is that if it is the 1st time i add record to this
datagrid and then update the checkbox to true.

thanks in advance for any help.


 Reply:
by:Cor Ligthert

 Hi jaYPee,

You can look what currentcellchanged event from the datagrid (and than check
in that the columnumber if it is the checkbox) and than the
currencymanager.endcurrentedit can do for you.

Not tested just an idea?

Cor


 Reply:
by:jaYPee

 thanks for the immediate reply. here's my code i used. it is working
the 2nd time i click the checkbox again. but didn't work the 1st time
i click the checkbox

DataGrid1.EndEdit(Nothing, DataGrid1.CurrentRowIndex, False)
DataGrid1.BindingContext(DataGrid1.DataSource,
DataGrid1.DataMember).EndCurrentEdit()

'save record first before adding course

SqlDataAdapter2.Update(DsStudentCourse1)




Posted by Xander Zelders



3 Comments:

Anonymous Anonymous said...

Mate, sorry I can't help you with your problem, but you just solved mine: datagrid.endedit - you little ripper!

Best Regards,

Baraholka

7:28 PM  
Anonymous Anonymous said...

You solved my problem too. I think maybe your first line, the "Nothing" should be something:


int _currentColumnIndex = DataGrid1.CurrentCell.ColumnNumber;
DataGridColumnStyle Nothing = DataGrid1.TableStyles[0].GridColumnStyles[_currentColumnIndex];


So, "Nothing" has become something.


DataGrid1.EndEdit(Nothing, DataGrid1.CurrentRowIndex, False);
DataGrid1.BindingContext[DataGrid1.DataSource,
DataGrid1.DataMember].EndCurrentEdit();

'save record first before adding course

SqlDataAdapter2.Update(DsStudentCourse1)

9:41 AM  
Anonymous Anonymous said...

I had the same problem...for me, the solution was

DataGrid1.CurrentRowIndex = DataGrid1.CurrentRowIndex;


Kurt

11:55 AM  

Post a Comment

<< Home

 
Previous Posts
    - How to Get info from MDI child
    - About a datagrid row
    - How to Pass Parameters to an Event
    - How to delete all the contents in a datagrid
    - Build error for VB.NET but not C#
    - Comparing datareader result to a string
    - Dataviews and constrained datasources?
    - Windows service not releasing object
    - How to Shut Down Server
    - How to wrap SendMessage



Disclaimer & Terms of Use | DotNet4All.Com concept & © 2004 - 2007 by Zelders² - Holland