This is a migrated thread and some comments may be shown as answers.

Always have an empty row in the grid

3 Answers 331 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rks
Top achievements
Rank 1
rks asked on 25 Nov 2009, 05:15 PM
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

3 Answers, 1 is accepted

Sort by
0
Roland
Top achievements
Rank 1
answered on 26 Nov 2009, 01:51 AM
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.
0
rks
Top achievements
Rank 1
answered on 04 Dec 2009, 04:19 PM

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

0
Roland
Top achievements
Rank 1
answered on 04 Dec 2009, 04:27 PM
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
Tags
Grid
Asked by
rks
Top achievements
Rank 1
Answers by
Roland
Top achievements
Rank 1
rks
Top achievements
Rank 1
Share this question
or