We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Setting CellValue in Databound grid adds extra row

Setting cell value programmatically to the last cell in a databound grid adds an extra row to the grid as well as sets the same value to column in the next row. For eg. this.gridDataBoundGrid1[this.gridDataBoundGrid1.Model.RowCount-1,1].CellValue = "1"; will add an extra row to the grid as well as sets the [rowcount,1] cellvalue to "1". Is there any I could change a cell value without adding new rows? I am using the Syncfusion Grid 1.6.1.0 Thanks in advance

12 Replies

AD Administrator Syncfusion Team October 10, 2003 11:04 PM UTC

If you want to change values in the AddNew row then you should first call Binder.AddNew() and after changing the cell value call Binder.EndEdit(). If you do not want the AddNew behavior supported by the grid then set AllowAddNew = false. Let me know if you need more info. Stefan


RK Rajeev Kulam October 13, 2003 04:49 PM UTC

This happens on an existing row (always the last but one row). Databound grid is adding a new row If I set cell value to the last row existing in the databound grid (not the add new row).


AD Administrator Syncfusion Team October 13, 2003 06:17 PM UTC

Sorry I misunderstood first. I see the problem and we'll get that fixed in the grid source code. A workaround would be in the meantime to set AllowAddNew = false before setting the value and resetting AllowAddNew = true after you changed the value. Stefan


DH Dave Hermans October 17, 2003 08:16 AM UTC

I have tried this workaround, but after resetting the allownew property the empty line is disapeared, making it impossible to add new records. if you manualy edit another cell, it does add a new line.


AD Administrator Syncfusion Team October 17, 2003 08:52 AM UTC

Attached is a project wher eteh work around seems to do ok. What are you doing differently?


DH Dave Hermans October 17, 2003 09:15 AM UTC

If i'm not mistaking the project contained 2 ways to clear the cell. I tried both. the first, with the clearcells command, ran ok without errors, but it didn't clear the cell. the second, with the enableaddnew, ran without errors and cleared the cell contents, but the extra empty line was gone. it reapeared only when manualy editing another cell.


AD Administrator Syncfusion Team October 17, 2003 09:30 AM UTC

I sent this particular project to test changing EnableAddNew on the fly to avoid the problem you described in your post. Did not pressing the button change the on the last line of good data in the grid? If you want to test the clear with the delete key in this sample, try setting the grid ListBoxSelectionMode to One. Otherwise, delete will be handled by the actively editing cell (and will not delete either the row or the whole cell contents, but instead will delete the next character in the string if there is one).


AD Administrator Syncfusion Team October 17, 2003 09:39 AM UTC

Looking at the code, it does have ListSelectionMode set. Sorry. What version of our library are you using? I tried this with 1.6.1.0 (pressing the delete key, and it seemed to work for me with that version.


AD Administrator Syncfusion Team October 17, 2003 01:23 PM UTC

The original problem posted at the beginning of this thread has been fixed in version 1.6.1.8, a private build. You can get that release by submitting a support incident and requesting it.


DH Dave Hermans October 20, 2003 07:09 AM UTC

Clay, we are using Essential suite 1.5.2.0. What i want the delte key to do is the same as it does in word for example delete the caracter. I have a seperate button to delete the whole line. I've tried setting the selectionmode to none, but it still deleted the line. Greetings, Dave


AD Administrator Syncfusion Team October 20, 2003 08:00 AM UTC

You might be able to do this from with the RowDeleting event.
private void gridDataBoundGrid1_RowsDeleting(object sender, GridRowRangeEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl; 
	if(tb != null)
	{
		e.Cancel = true;
		if(cc.IsEditing)
		{
			if(tb.SelectionLength == 0)
				tb.SelectionLength = 1;
		}
		else
			tb.SelectAll();
		tb.SelectedText = "";
	}
}


DH Dave Hermans October 20, 2003 08:20 AM UTC

Thanks Clay, this is what i need. Greetings, Dave

Loader.
Up arrow icon