Gridview rowupdating datakey
These are the methods that will be invoked from the Presentation Layer. The rationale behind using two methods is that in some circumstances, a user might want to update the category s picture along with its other fields, in which case the user will have to upload the new picture. To remedy this, click on the Configure Data Source option from the Object Data Source s smart tag to launch the wizard.The uploaded picture s binary data can then be used in the column as well, then we d need to provide that information as well. The first screen shows that the Object Data Source is configured to work with the Note Upon completing the wizard, Visual Studio may ask if you want to Refresh Fields and Keys, which will regenerate the data Web controls fields.Currently, the Object Data Source is not yet configured to include updating support, so let s add that in.Click the Configure Data Source link from the Object Data Source s wizard and proceed to the second step.
The remainder of this tutorial delves into adding update capabilities to the brochure and picture.
This wizard starts by asking us how the Table Adapter query should access the database. The next step prompts for the type of query to be generated. Update, false)] public bool Update Category(string category Name, string description, string brochure Path, byte picture, int category ID) [System. As we discussed back in the An Overview of Inserting, Updating, and Deleting Data tutorial, the Grid View provides built-in deleting capabilities and these capabilities can be enabled at the tick of a checkbox if the grid s underlying data source supports deleting.
Since we re creating a query to add a new record to the (Click to view full-size image) In addition to updating the DAL, we need to update the BLL to include methods for updating and deleting a category. Currently the Object Data Source the Grid View is bound to () does not support deleting.
To accomplish this, create an event handler for the Radio Button List s .
With this code in place, take a moment to test out the editing interface. Initially, the Use current brochure option should be selected. If the third option is selected, the File Upload control is displayed, otherwise it is hidden.