title: Data Insertion Error
body: <p>I am working on a WPF app. There are two problems generated in my code.</p>
  
  <p>1 - when I entered values it assigned 0 to ID</p>
  
  <p>2 - secondly after inserting value when I stopped debugging and again started it, it showed value of Id but it didn't show entered value.
  Attached Images will help you to understand my problem!
  Let me Explain with the help of these attached images:
  Here first image is showing that when i entered a value "assignment12_new", it accepted a value but assigned 0 to its ID, then I closed this window and pressed F5 to start debugging again, Second image is showing result of this debugging, Here value of ID was appeared but its value that was "assignment12_new" didn't. As it was not stored in database. I don't know what' is wrong with my code.  </p>
  
  <p><img src="https://i.stack.imgur.com/3N4uB.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/SX5nV.png" alt="enter image description here"></p>
  
  <p>Here is my code:  </p>
  
  <pre><code> private void dgData_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)  
   {
          if (e.EditAction == DataGridEditAction.Commit)
          {
              //Database context
              DataClasses1DataContext objNewContext = new DataClasses1DataContext();
  
              //Creates new object to insert new Record in Database
             Assignment objStudentDetail = new  Assignment ();
  
              //Check if record is not is table then preoceed to insert
              if (!objContext. Assignments.Contains(student))
              {
                 // objStudentDetail.assignment_title = string.IsNullOrEmpty(student.assignment_title) ? student.assignment_title : student.assignment_title.Trim();
                  objStudentDetail.assignment_title = student.assignment_title == null 
                                   ? string.Empty
                                   : student.assignment_title.Trim();
                  //This will insert new record in table
                  objNewContext. Assignments.InsertOnSubmit(objStudentDetail);
  
                  //This will update changes in database
                  objNewContext.SubmitChanges();
  
                  //Show message when record is inserted
                  txtStatus.Text = "Success: Data Inserted";
              }
              else
              {
                  //this will update changes in database for edit operation in database
                  objContext.SubmitChanges();
                  //Show message when record is updated
                  txtStatus.Text = "Success: Data Updated";
              }
          }
      }
  </code></pre>