e.Row.RowState == DataControlRowState.Edit not works on Alternating Rows


The combine Alternatiing/Edit state fail the comparsion logic.


if ((e.Row.RowState & DataControlRowState.Edit) > 0)

Attach already changed object to a data context


Using one data context for selecting data and another for submitting the changes made. The problem is that once you  attach an object to the new context you'll lose tracking of all changes made to the object.

All changes will lost after you save change.


Call the SetModifiedProperty method  to notify the ObjectStateManager of the data context about the changes.


AdventureWorksLTEntities context = new AdventureWorksLTEntities();
            Product product = context.ProductSet.FirstOrDefault();
            if (product != null)
                product.ListPrice += 10; // product.EntityState is set to Modified

            AdventureWorksLTEntities newContext = new AdventureWorksLTEntities();

            context.Detach(product); // product.EntityState is set to Detached
            newContext.Attach(product);  // product.EntityState is set to Unchanged

            ObjectStateEntry state = newContext.ObjectStateManager.GetObjectStateEntry(product);
            state.SetModifiedProperty("ListPrice"); // product.EntityState is set to Modified


ASP.NET not posting back with javascript modal popup


Ensure you include the following within the <head> tag:

 <base target="_self" />