GridView Row Add

2 posts, 0 answers
  1. Thi Han
    Thi Han avatar
    15 posts
    Member since:
    Oct 2011

    Posted 12 Jan 2012 Link to this post

    i want  to know  how to add the rows added by the users to be added on the top
    and also want to know how to add the rows that added by programatically to be added on the top.

    i use the bound mode.i bind List<> to the "gridview.DataSource".
     
     
  2. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 16 Jan 2012 Link to this post

    Hello Thi Han,

    Thank you for the additional details.

    I would suggest using BindingList instead of a List, since the BindingList implements the IBindingList interface internally, which allows the grid to get notified for changes in the list. The approach for the first scenario is to handle the UserAddedRow event of RadGridView, where you can get the newly added row, save its DataBoundItem (the custom object) to a variable, then remove the row from the grid Rows collection and insert the saved object in your BindingList at position 0. The approach with the programatically adding rows is to simply create the custom object and insert it at position 0 in your BindingList.

    Attached you can find a sample application.

    I hope that you find this information helpful.

    A bit off topic, I would like to mention that it is possible to write multiple posts in one thread, so you do not need to open a new thread for each post, i.e. you could post the additional details straight in the previous thread that you have opened.
     
    Regards,
    Stefan
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top