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
close icon

Complex Databinding Issues

I am using the GridDataboundGrid and wish to bind to a table on my SQL server. Here is the issue: several row validation rules must be considered BEFORE any updates / inserts / deletes are done. For example, before an insert, I must ensure that certain columns in a row contain a certain value; and before a delete, I must ensure that ALL column values in a row are deleted, else, the delete should not fire. I will also be colorizing rows to indicate several row situations. My question is, can I facilitate these requirements using databinding? If so, in what event would it be best to include the validation checks (keeping in mind that the user might be modifying only a single cell, or a range of cells), and then process either the update / delete / insert? I am not using any of the wizardry to create my SQL connection, adapter, dataset, parameters or commands, as I have several dynamic values that must be used. (I have attached a txt version of my code) On a side note, I have a checkbox control in one of my columns and wish to save its value to the database with a '0' or '1' value, depending on its state, however, I keep getting an message that a or value is passing through. How can I avoid this? Thanks for any assistance.

1 Reply

AD Administrator Syncfusion Team February 14, 2003 02:26 PM UTC

> I am using the GridDataboundGrid and wish to bind to a table on my SQL server. Here is the issue: several row validation rules must be considered BEFORE any updates / inserts / deletes are done. For example, before an insert, I must ensure that certain columns in a row contain a certain value; and before a delete, I must ensure that ALL column values in a row are deleted, else, the delete should not fire. I will also be colorizing rows to indicate several row situations. > For colorizing you should handle PrepareViewStyleInfo. > My question is, can I facilitate these requirements using databinding? If so, in what event would it be best to include the validation checks (keeping in mind that the user might be modifying only a single cell, or a range of cells), and then process either the update / delete / insert? > You can do validate the row in the RowLeave event. If the row was edited (Binder.IsEditing) then you could validate all columns and if some do not meet the criteria you set e.Cancel = true. For deleting values I am not exactlty sure. There are two events related to deleting cells or rows: Model.ClearingCells and GridDataBoundGrid.RowsDeleting / GridDataBoundGrid.RowsDeleted. Try them and see what better fits you. > On a side note, I have a checkbox control in one of my columns and wish to save its value to the database with a '0' or '1' value, depending on its state, however, I keep getting an message that a "true" or "false" value is passing through. How can I avoid this? > Do this: style = model.BaseStylesMap["Standard"].StyleInfo; style.CheckBoxOptions.CheckedValue = "1"; style.CheckBoxOptions.UncheckedValue = "0"; Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon