none
linq selected row RRS feed

  • Question

  • hi how do i auto select back the new inserted row in a gridview using LInq? It is a window app

    i tried this.. but not valid.

    dgUser.Rows.OfType<DataGridView>().FirstOrDefault((row => row.Columns["empId"] == user.Id)).Select();

     

    Friday, January 7, 2011 8:26 PM

All replies

  • ok i wonder why there is no reply to my thread. Please inform me if my question is not clear.

     

    Sunday, January 9, 2011 1:51 AM
  • Hello belinq,

    Welcome to the MSDN Forum and thank you for posting here.

    Based on your description, you want to get one item which is new inserted to the database. In my opinion, you can get the max ID item and that is the new one .

    Here is the sample code:

    var query = datacontext.TableName.Where(f => f.ID ==datacontext.TableName.Max(m => m.ID));

     If I misunderstand you or you have any question, please feel free to let me know.

     

    Have a good day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 10, 2011 6:32 AM
    Moderator
  • hi thanks for the reply. but i think u have missed out the highlight part

    imagine u have a gridview of 20 rows, a textbox and a button.

    after i save the 21st record successfully, the 21st record will be appeared to the gridview and how do i auto highlight that 21th row?

     

    Monday, January 10, 2011 7:53 AM
  • Hello belinq,

    Sorry for late. Have you solved your issue? I think it's very hard in the behind to make it work as your description. Why don't you try to use AJAX, I think it must be the better choice.

    What do you think of this?

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, January 18, 2011 6:19 AM
    Moderator