I am attempting to construct a formview that will edit two related objects at once.
In basic terms, I have a Linq To SQL object of teacher which has exactly one school. The formview has no problem displaying the data, but when in edit mode will only save the changes done to the parent object. Changes to the school data are seemingly ignored
Is there any way to achieve the kind of thing I want here?
Thanks,
This is probably similar to what I'm doing, although I'm not using Linq. I'm using a vanilla ObjectDataSource and displaying data in a drop down list via a different data source. Add a new Event for the FormView that is called during the "ItemUpdating" event. Embed code to directly save your changes in that event. Then as the FormView is saved, everything else is saved.
If you want it to be saved after the FormView, use the ItemUpdated event instead. It's a bit of a manual process, but it does get around the problem.
Related
I've read tons of sites on this. There are many "Examples" if you call some code with no explanation of how it was generated (design view vs typed) an example or just want to use simple select and update statements.
I have a Gridview. I am populating it using code from a stored proc. Now I want to edit the data. I have nothing set in the properties of the Gridview through design view (datasource, columns, etc.) My question is, how can I set this to allow editing and use a SP to send it back to the database?
Do I have to now manually create columns with code since I chose to not set properties in the design view?
Is it better to set the properties in design view and go that route? I started that way, but had problems when it came to updating with a SP.
I guess the whole do it in the designer vs do it in code thing has me confused.
I started adding RowEdit, RowCommand, etc. to the html and c#, but still don't see the EDIT/CANCEL on the webpage when I run it.
Learn to use the ObjectDataSource. It gives you maximum freedom of what way of storing the data you use - you delegate the select, update and delete to an external class where you just write your code which uses ado, linq, hibernate, a webservice or just anything.
Coding your views directly against fixed database structure would hurt you sooner or later.
I took over a very old project written in VB6, it's a mess and I don't really know VB so it would be great if someone could help me.
I have a Data control which gets records from an Access database which I would like to replace with some kind of drop down list - I thought about ComboBox. Unfortunately I cannot get records from the database in the same way as with Data, so I thought about populating ComboBox based on what's in the Data control. How can I achieve it? Or is there a better way to do it?
My last resort is to create all database methods manually in order to replicate Data's behaviour for ComboBox but I think it's too much effort for such a small change.
Thanks in advance!
The Data control does more than just let them browse through the records, it manages the database, current record, data binding, etc.
The easiest way to do what you want is to hide/move the data control and use its .Recordset.Find*() methods.
Note that DAO is archaic and has been supersceded at least once for VB6 (with ADO)
I have been trying to find a solution for this for a while but I've only managed to find junk on outdated forums.
I am using VB6 and I want to display data in a tabular form. I thought about using a DataGrid but I can't figure out how to add rows to the grid.
Note: The DataGrid is not bound to a recordset.
Is there any way to add the data to the GridView without storing it in a recordset. And is there a better VB6 control to use in this situation?
DataGrids are designed to be used bound to a data source, though it can be a custom data source object and not just an ADO Recordset.
For general display you might want to use the MSHFlexGrid (or the VB5 holdover MSFlexGrid).
I am looking for some examples for gridview for common tasks like displaying, editing, deleting, paging, sorting, batch updates etc, but WITHOUT using any datasource controls. I would like to bind the data in the code to custom object collection. all the samples I found on the web so far use some data source control, I think Enterprise applications shouldn't be using this pattern. objects in my solution have only business logic and no data access code. instead I use manager objects to do this.
if you have any examples of gridview that performs the common tasks without using any data source control, can you please share them? that would be very helpful. thanks.
Editable GridView in ASP.NET 2.0
Sorting a GridView Bound to a Custom Data Object
I'm currently working on a reasonably complicated data input form, based around ASP.NET Web Forms. After the form has been completed, we'd like to offer a chance for the user to review their input before actually submitting the form (as well as going back to make changes to their data if requried).
Due to the large number of fields, I wanted to use a FormView control due to it's automatic databinding ability, removing a lot of tedious code, however there doesn't seem to be a simple way to offer this functionality.
At the moment, my current approach uses an ObjectDataSource to bind all the form fields. I've created two 'modes' of operation on the data source; one mode temporarily saves the object to the user Session (allowing retrieval again later for read-only/edit modes - this facilitates the review/modification functionality), while the second mode actually does the database insertion.
While this seems reasonably robust at this point, it still feels quite dirty to me. I know I could use a Wizard/Multiview type approach, but then you lose out on the niceties of automatic databinding (I believe?). I'm sure this is a fairly common problem, so how is this typically done in a Web Form environment?
Thanks!
The project I am currently work on uses a custom wizard setup (not the asp.net 2.0 wizards). It comprises of the several steps your wizard may require, and when you go from one step to the next, the code saves the values into a final step (a read-only review). When the user gets to that last step, they can go back to the step that needs to be updated. When happy, the user submits the wizard, and the data is saved to the db. It is basically a series of panels that have their visibility toggled.
You should be able to still use the ObjectDataSource for each of the editable fields, having the panel or mutliview being visible or not shouldn't affect the binding. When you go from one panel to the next, you can update a read-only step (like I said before) while keeping the editable controls bound to the ObjectDataSource. When you go back to any steps that need to be modified, you are still bound, so when you make any changes and click submit or whatever the button is, it should use the ObjectDataSource.
Anyone else have any other ideas?