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

add value in new row

I have gridDataBoundGrid and property enableAddNew is true. I want fill some cellValue in last row when I enter in last row.

7 Replies

AD Administrator Syncfusion Team February 23, 2004 09:24 AM

Maybe the information in this forum thread will help you do what you want. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=5027


JA Jaris February 24, 2004 07:22 AM

Thank you. It works fine. But I can''t cancel saving row in event RowSaved. When I set e.Cancel = true in event RowSaved, new row creates in grid when I press arrow keys next time in grid.


AD Administrator Syncfusion Team February 24, 2004 07:41 AM

RowSaved is too late. Try the RowLeave event, and if you want to not save teh changes, then have code similar to
private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
	if(e.IsAddNew && dontWantToSave )
	{
		this.gridDataBoundGrid1.CurrentCell.CancelEdit();
	this.gridDataBoundGrid1.Binder.CancelEdit();
	}
}


JA Jaris February 24, 2004 08:20 AM

Event GridRowEventArgs haven''t property IsAddNew (e.IsAddNew).


AD Administrator Syncfusion Team February 24, 2004 08:27 AM

It does in the 2.0 code base. The code I listed was taken from a working sample. In earlier versions, you can test whether you are on the addnew row by checking something like if(e.RowIndex == this.gridDataBoundGrid1.Model.RowCount) { }


JA Jaris February 25, 2004 07:21 AM

Thank you very much, I have another problem. I have grid with binding to dataset. This dataset has column named ID with NOT NULL constraint but this column isn''t in grid. When I create new row in grid and this row is saved, application displays message "Column ID does not allows nulls". I don''t know how can I fill this column in dataset. I tried to fill this column in event RowSaved but it was late. And before event RowSaved the row isn''t in dataset. I added this column in grid and set invisible and I filled in event RowLeave. It works fine but I''m looking for some simpler way.


AD Administrator Syncfusion Team February 25, 2004 07:53 AM

Can you set the DefaultValue property on the DataColumn? Then when DataTable.NewRow is called, this column should be populated with teh default value. myDatatable.Columns["ID"].DefaultValue = "something";

Loader.
Live Chat Icon For mobile
Up arrow icon