When we created the SqlDataSource control in ManageCategories.aspx, we had it return the CategoryID, UserId, and Name column values. When we're configuring the SqlDataSource control to generate the INSERT, UPDATE, and DELETE statements, it automatically creates the UPDATE and INSERT statements to update and insert all nonprimary key columns. In this case, that's UserId and Name. But, you're correct, the UserId value does not need to be updated when updating just the Name column, as through the GridView. You could manually adjust the SqlDataSource control's UpdateCommand and UpdateParameters properties to have the UPDATE statement update only the Name column; in that case, you wouldn't need to programmatically set the UserId value in the GridView's RowUpdating event handler. If you wanted to go down this path, you would remove the reference to the UserId value and parameter, setting the SqlDataSource control's UpdateCommand property to UPDATE [Categories] SET [Name] = @Name WHERE [CategoryID] = @CategoryID You would also remove the <asp:Parameter Name="UserId" /> line from the SqlDataSource control's <UpdateParameters> section. |