I am Ultrawebgrid control which is associated with a SQL datasource for displaying and inserting data. Currently the newly the newly added rows to the webgrid are saved automatically in the database on postback(i.e of click of a button). How I disable this automatically saving of data.
I need to have more control over the timing database updation.
Thanks,Rajiv
Hello,
In a typical asp:sqldatasource control you can autogenerate the SELECT, UPDATE, DELETE and INSERT statements for the respective table using the asp:sqldatasource wizard. In this case I believe the easiest way to proceed would be to just delete the auto-generate INSERT statement and proceed with your custom code in the AddRow event of the grid.
Alternatively, you can just hook the AddRow event and set the eventArgs.Cancel property to true so that the event is cancelled and then add your custom code, e.g.
protected void UltraWebGrid1_AddRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { e.Cancel = true; // custom code here }
Also, I recommend reading this excellent blog post by Tony Lombardo on databinding and automatic updates here:
http://blogs.infragistics.com/blogs/tony_lombardo/archive/2008/01/29/demystifying-infragistics-webgrid-databinding.aspx
It provides many clues and insights on how databinding / autoupdates works and how they can be customized.
HTH,
Thank you for the Reply.
I am using the the Stored procedures for selecting and inserting data in the SQLDataSource. I tried to use the UltraWebGrid1_AddRowBatch event to cancel the insert operation using e.Cancel = true;. But for some reason the insert opertaion is not cancelled and the data gets inserted in the database.
Could you please let me know why this is happening and how to fix this?
Thanks & Regards,
Rajiv