Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DGV acting strange ; clearing my entries
 

DGV acting strange ; clearing my entries

Hi

I am working with msvs 8 with linq and datagridview

I have been working in this problem for the last 4 days. It is becoming like gambling. The more time I spend on it the more I insist to solve it.


------
I have a table named "Contract" indexed by ContractNumber

I have an add button and save button. If the record is not newly inserted, the save button works fine. But for newly inserted ContractNumber I have problems as described down below the code.

The add button opens a dialog form, which collects only the contract number from the user. All remaining entries are supposed to be made directly into the datagridview after checking that the contract number does not exist in the table.


the add push button
----------------
conttract = new Contract();
contract.ContractNumber = contractDialog.ContractTextBox.Text.ToString();
dbContext.Contracts.InsertOnSubmit(cont);
Validate();
dbContext.SubmitChanges();




the save push button
_________________
Validate();
dbContext.SubmitChanges();



the problem I am facing is when I enter for example the contractor name or description into the grid cell, and click the save PB, the cell immediatly goes blank and I lose the entry. When I try for a second time, it works and the entry makes it to the database.

Why do I lose the entry the first time?

I will appreciate any help
ChromY  Friday, July 17, 2009 1:24 PM
This is very strange

5 minutes after posting I found the answer

The save button event must start with Validate(), or Endedit() to force the grid to end the edit.

Working as a clock now

thanks anyway.


ChromY  Friday, July 17, 2009 2:55 PM
This is very strange

5 minutes after posting I found the answer

The save button event must start with Validate(), or Endedit() to force the grid to end the edit.

Working as a clock now

thanks anyway.


ChromY  Friday, July 17, 2009 2:55 PM

You can use google to search for other answers

Custom Search

More Threads

• How do you scroll a DataGridView through code?
• DataGridView VerticalScrollbar Member
• Show relational data on datagridview
• Pass dataset to Child Form
• displays records from two different tables
• DataGridView - How to log changes to a cell?
• Gridview cell add and display
• Datagrid does not apply format after form loads
• filter a DataView (where rows in column "Date Created" are null).
• Saving modified date