(See Filtering Database Data with Parameters for more information on using parameters with the data source controls.) For the Sql Data Source control, you can access the parameter value using Protected Sub Categories Data Source_Selecting(By Val sender As Object, By Val e As System. An exception could occur if the database was down, an illegal parameter value was used, the action violated a constraint, or for some other reason.
Moreover, if an exception has transpired, the property can be set to True to indicate that the exception should be suppressed.
When the Object Data Source calls your data object, if the result is an exception it will call your post event event-handler (Selected, Deleted, etc).
The Event Args has two properties for managing exceptions, one is the Exception itself, the other is a boolean, Exception Handled.
The post-action event handlers are most commonly used to determine how many rows were affected or to detect if the operation raised an exception. NET 2.0 introduced a number of new Web controls designed for accessing and modifying data.
The pre- and post-action event handlers are also quite helpful when debugging. These controls allow page developers to declaratively access and modify data without writing any code to perform the data access.
For example, the Sql Data Source and Object Data Source raise their event indicates, among other things, if an exception occurred during the operation.
Similarly named pre- and post-action events fire during the updating, inserting, and deleting processes, as well.
The business-logic class does not need to be aware of how the class that it's calling persists the data. Find Control("LName"); Text Box Age = (Text Box)row. For more information on handling exceptions in the post-action event using the Object Data Source, check out Handling BLL- and DAL-Level Exceptions in an ASP. For an example using the Sql Data Source control, check out Fredrik Normen's blog, specifically Handle the Data Source Control Exception on Your Own.When retrieving or modifying data with the Sql Data Source or Object Data Source controls, pre- and post-action events fire.The parameter's source could be specified declaratively, using a hard-coded value or pulling its value from a Web control on the page, a querystring value, and so on. Sql Data Source Selecting Event Args) Handles Categories Data Source. Instead of receiving a Command object in the event handler, the Object Data Source's pre-action event handlers are passed a dictionary object called , where the Integer input parameter department ID is used internally to return only those employees belonging to the specified department. In the post-action event handler, the number of affected rows is reported as is whether an exception occurred.Regardless, the value of the parameter can be examined and modified (if needed) in the event handler. To programmatically assign this input parameter value in the Object Data Source's Protected Sub Categories Data Source_Selecting(By Val sender As Object, By Val e As System. The Object Data Source's post-action event handler is also passed the value returned by the invoked object library method (if any).The Sql Data Source and Object Data Source controls are the two most commonly used data source controls, and they provide a means for retrieving and modifying data from either a database or object library, respectively.