The next line in that block is the critical part of the code and that is to determine the Edit state.is a bit tricky especially if you are not really familiar on how stuff works within Grid View. Edit isn’t really accurate and you might get an exception when doing so. Therefore, the Row State could indicate that you are in the Edit state and the Alternate state.First we check the Row Type to make sure that we are only manipulating the rows of type Data Row.
This method uses the LINQ syntax to query the Data Source based on the parameter that was passed in.Now looks like we already have some sample source of data to work on.Note: Before you proceed, make sure that you already know the basics of using the Grid View control and how to bind it with data as I will not include the details of doing edit,update or delete scenarios for this exercise.Scenario: As a recap, Cascading Drop Down List enables a common scenario in which the contents of one list depends on the selection of another list.If you notice, I’ve set the Selected Value for the ddl Make and ddl Model Drop Down Lists so that by the time the user clicks Edit the Drop Down List will be pre-selected with the previous item the user has chosen.
The ddl Product Make_Selected Index Changed event is where we actually do the cascading feature by populating the second Drop Down List based from the value selected from the first Drop Down List.The Get Product Model() method gets all the available Models for each Makes.The Get Product Model By Make() method gets the specific Model item and its details based on the Product Make ID.Finally, the last column is a Command Field with Show Edit Button enabled.This will generate the Edit link when the Grid View is bounded with data. This is where we store the list of Makes of the product.Hence, you cannot do a simple equality check when you are on Edit mode.