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 02:24 PM UTC

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 12:22 PM UTC

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 12:41 PM UTC

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 )

JA Jaris February 24, 2004 01:20 PM UTC

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

AD Administrator Syncfusion Team February 24, 2004 01:27 PM UTC

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 12:21 PM UTC

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 12:53 PM UTC

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";

Live Chat Icon For mobile
Up arrow icon