Asp net objectdatasource not updating
A class marked [Serializable] would have code added to save and load a saved object automatically. The true parameter marks the field as a primary key, which will automatically add the field name to the “Data Key Names” list of the Grid View.
Other options you can add are is Identity, is Nullable, and length.
The Object Data Source is the other half of the magic, connecting the Grid View to the data and managing any filter controls.
When using Data Sets and Table Adapters, everything is a dream, but when using your own custom objects the wizards and property pages act like you don’t exist.
The good news is with a little extra code, we can have our custom objects act just like fancy Data Sets.
For the Grid View to show the fields in the “Edit Fields…” design time dialog, you’ll need to expose the fields as Properties.A very simple class for a Person could look like this: If you’ve not seen the [ ] syntax before, these are Attributes.Note, this just describes the field, it’s up to you to enforce these constraints.The IEquatable part isn’t something for the Grid View, but to help us manage our custom object.
In this example i am explaining how to Insert Edit Update Grid View With Object Data Source In Asp. For this i've created a simple database with a table named Details having 3 columns ID, Name and Location. Now right click on solution explorer and select add new Item To learn how to configure database connection and connection string for this example read my article Insert Edit Delete record in Grid View using Sql Data Source Item Template and Edit Item Template Right click on Data Set designer window and select Add Save the solution Now go to html markup of the page and change the html code of gridview according to code written below to implement Item Template and Edit Item Template I'm using Bind method in Edit Item Template of Grid View so we do not need to write and code in Code Behind The html source of page should look like Save,build and run the application Hope this helps Download sample code attached Related posts: Insert Edit Delete record in Grid View using Sql Data Source ASP.The Grid View control is one of the great time savers of ASP. Sorting, paging, editing, deleting, and even AJAX (set Enable Sorting And Paging Callbacks to True) is included out of the box.