Always have an empty row in the grid

4 posts, 0 answers
  1. rks
    rks avatar
    22 posts
    Member since:
    Feb 2009

    Posted 25 Nov 2009 Link to this post

    Hi,

    I am using Visual Studio 2008, Rad Conrtols for ASP.NET AJAX Q2 2009 and .net Framework 3.5 and C# Programming.
    I am using RAD Grid to display the data and in line mode to edit the data.
    i want to always have an emptyrow in the grid so that when the user doule clicks on this empty row, the grid goes into edit mode, user clicks on save and the new row is added.
    If there are any rows in the grid already, user can edit the rows by double clicking in a cell and when double click on the empty row user can type in new data.
    Thus when clicked on save button, the data in the empty row is added and the data in the other rows is updated.

    Thanks,
    RKS
  2. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 25 Nov 2009 Link to this post

    Hello,

    There is a number of ways of achieving required funcionality.

    One approach would be for example:

    Grid is bound to List<Person>. You add the last person as 'empty' object with some predefined id like:
    Person p;
    p.Id = -1;   //define a mock person that serves as edit mode.

    In grid's double click event you would enable the edit mode on the clicked row. Then in 'save' event you would know (by comparing p.Id) if this is supposed to be a new item.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. rks
    rks avatar
    22 posts
    Member since:
    Feb 2009

    Posted 04 Dec 2009 Link to this post

    Hi,

    Thank you for the suggestion. Can you please help me solve the below situation.

    When the rad grid is in edit mode (in line editing) by double clicking a row, and i am entering/editing data in the last cell(column) of the last row,I want to display an empty row below this row so that i can add that new data row. Also want i save the data in the current row when i move to the below new empty row and double click it.
    I know that empty row can be added using the below code in needdatasource event: 
    DataRow myrow = mytable.NewRow();

            mytable.Rows.Add(myrow);

    Thanks,
    RKS

  5. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 04 Dec 2009 Link to this post

    Hello,

    When you double click the row to be edited, you would check if this is the last row (meaning the new row). If so, you would add another empty row.

    Roland
Back to Top