The Grid View calls the configured Get Products method, which in turn is using Entity Framework Code First to simply return the Products property on my Northwind data context instance.
It's important that the Data Key Names property is set to the primary key (or keys) of the model type, so that the Grid View can round-trip this value with the page between the browser and server.
In those cases, it's a better approach to first load the object to be updated from the database (using its primary key), and then explicitly instruct the Model Binding system to bind the data-control values onto the members it can.
Let's change our update method to use this approach: This time, the Web Forms Model Binding system will populate the product Id parameter from the data-controls Data Keys collection (it does this implicitly; no value provider attributes are required).
This is the fifth in a series of blog posts I'm doing on ASP. Model Binding is an extension of the existing data-binding system in ASP.
NET and Visual Studio include a ton of great new features and capabilities. NET 4.5 you'll see a bunch of really nice improvements with both Web Forms and MVC - as well as in the core ASP. Today's post is the third of three posts in the series that talk about the new Model Binding support coming to Web Forms.
We can enable the Grid View's inline row editing support by setting the Auto Generate Edit Button attribute to "true".