Data Platform Developer Center > Data Platform Development Forums > LINQ to SQL > Update Cells in Datagridview - Linq to SQL
Ask a questionAsk a question
 

QuestionUpdate Cells in Datagridview - Linq to SQL

  • Tuesday, October 13, 2009 10:01 AMNeeraj Bajaj Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hi all,

    i am binding datagridview with linqtosql query .

    i want to edit information in current row in grid when i click on edit button in datagridview.

    private

     

    void dgTracker_CellClick(object sender, DataGridViewCellEventArgs e)

    {

     


    if


    if

     

    (dgTracker.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name.ToString() == "imgEdit")

    {

    dgTracker.CurrentCell = dgTracker.Rows[e.RowIndex].Cells[4];

    dgTracker.Rows[e.RowIndex].Cells[4].ReadOnly =

    false;

    dgTracker.BeginEdit(

    true);

     

    // // dgTracker.EndEdit();

    blnEditFlag =

    true;

     

     

    MessageBox.Show( dgTracker.Rows[e.RowIndex].Cells[4].EditType.ToString());// = new string{ "Neeraj"};

     

    //dgTracker.CurrentCell.Value = "Nb";

    }
    }

     

    MessageBox.Show("cell value changed");

     

    if (blnEditFlag == true)

    {

     

    db.SubmitChanges();

     

    // db.Refresh(System.Data.Linq.RefreshMode.KeepChanges, rm);

    }

    the main problem is the value in current cell is not the new value which is modified and in case u check on cellleavevaluechnaged event the currentcell values it is still the old one.

    and in case i need to change value of current cell mannually also it doesnt change it.

    please help


    NB

All Replies

  • Wednesday, October 14, 2009 7:11 AMLingzhi SunMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi NB,

     

    The forum here is mainly for application development compatibility issues for different versions of Windows.  I think LINQ to SQL forum would be more appropriate for the current issue. 

     

    How do you bind the LINQ to SQL query?  Could you please provide some codes?   If the query result is some anonymous type objects, I don’t think they are editable. 

     

     

    Have a nice day!

     

     

    Best Regards
    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Tuesday, October 20, 2009 4:03 AMLingzhi SunMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi NB,

     

    How is the problem now?   If you need further assistance, I recommend you post it at LINQ to SQL forum.

    Have a nice day!

    Best Regards,
    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Monday, November 02, 2009 11:41 AMqasemt Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    im used is BindingSource For any Edit in to DataGrid ...

    if (dgTracker.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name.ToString() == "imgEdit")
    
    {
    
    
               ((ClassName)clientsBindingSource.Current).LastName = "Nik";
               clientsBindingSource.EndEdit();
               clientsBindingSource.ResetCurrentItem();
    
    }