Home All Groups Group Topic Archive Search About

GridViewUpdateEventArgs not including complete set of OldValues and NewValues

Author
31 Jan 2006 10:48 AM
Stephan Steiner
Hi

I have a GridView with 10 columns. However, when the RowUpdating event
fires, the GridViewUpdateEventArgs.OldValues collection only contains 8. It
seems to be missing two (always the same) but I can't find any logic to the
behavior. I use a combination of standard and template fields. One missing
column is a read-only, non templated, colum where I apply special formatting
to a date string, the other is a template field (non editable). I have two
other template fields using custom formatting (and editable), which are
returned just fine.

Note that I changed the underlying data source a bit this morning (added two
additional column which I map to the datakey but which are not displayed)
and I opted not to refresh the schema (now when I try it does nothing)
because I'm afraid it would mess up my grid customizations.

Also, while the NewValues contains all 4 fields that are editable and thus
should be send back, the one that maps to a multi column TextBox in a
TemplateField is always null (and it has been like that prior to the changes
I made to the datasource).

Does anybody have any ideas how I can get all the values I'm looking for
without having to resort to extract controls from the grid and read their
values? After all, that's what the GridViewUpdateEventArgs class should be
good for, right?

Regards
Stephan

Author
31 Jan 2006 1:28 PM
Christopher Reed
This is how I believe these values should work.

Keys (which you haven't mentioned) is a dictionary of the primary key fields
and their corresponding values for the selected row.

OldValues is a dictionary of all fields that are displayed and their
corresponding values.  I discovered that if you hide a column/field in a
GridView, then it's not accessible like a column in a DataGrid is.

NewValues is a dictionary of all fields that have been revised and their
corresponding new values.  I believe that if it hasn't changed, then it's
not included in NewValues.

Hopefully this might clear up some of your issues and then we can address
any that remain.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

Show quoteHide quote
"Stephan Steiner" <stei***@isuisse.com> wrote in message
news:eSrnuPlJGHA.532@TK2MSFTNGP15.phx.gbl...
> Hi
>
> I have a GridView with 10 columns. However, when the RowUpdating event
> fires, the GridViewUpdateEventArgs.OldValues collection only contains 8.
> It seems to be missing two (always the same) but I can't find any logic to
> the behavior. I use a combination of standard and template fields. One
> missing column is a read-only, non templated, colum where I apply special
> formatting to a date string, the other is a template field (non editable).
> I have two other template fields using custom formatting (and editable),
> which are returned just fine.
>
> Note that I changed the underlying data source a bit this morning (added
> two additional column which I map to the datakey but which are not
> displayed) and I opted not to refresh the schema (now when I try it does
> nothing) because I'm afraid it would mess up my grid customizations.
>
> Also, while the NewValues contains all 4 fields that are editable and thus
> should be send back, the one that maps to a multi column TextBox in a
> TemplateField is always null (and it has been like that prior to the
> changes I made to the datasource).
>
> Does anybody have any ideas how I can get all the values I'm looking for
> without having to resort to extract controls from the grid and read their
> values? After all, that's what the GridViewUpdateEventArgs class should be
> good for, right?
>
> Regards
> Stephan
>
Author
31 Jan 2006 4:22 PM
Stephan Steiner
Christopher

What you described is how it should work. Unfortunately, in my case it
didn't. OldValues lacked two fields, and NewValues lacked one (as it turns
out.. I completely forgot that I had another custom field and since you
can't mark them read-only, they should all be included) and had one always
set to null even though there was something entered in the GUI.

I manually checked the aspx source to make sure everything is proper, but
for the life of it, these fields were just missing, or empty (in case of one
of the newvalues). In the end I needed another page that looks almost the
same so I created that from scratch, and it worked as it should. Finally I
scrapped the old page, redid the grid (with all the custom formatting, it
sucked to lose that but I just had to get it done) and voila, things work as
they should.

So now the question remains, could an update of the underlying datasource
(it's a view in this case) have this effect on a grid? And how can you
resynchronize the grid with the datasource without losing all your custom
formatting (template fields, custom column selection from the datasource,
read-only fields).

Stephan

Show quoteHide quote
"Christopher Reed" <carttu@nospam.nospam> wrote in message
news:OSMc9omJGHA.3912@TK2MSFTNGP10.phx.gbl...
> This is how I believe these values should work.
>
> Keys (which you haven't mentioned) is a dictionary of the primary key
> fields and their corresponding values for the selected row.
>
> OldValues is a dictionary of all fields that are displayed and their
> corresponding values.  I discovered that if you hide a column/field in a
> GridView, then it's not accessible like a column in a DataGrid is.
>
> NewValues is a dictionary of all fields that have been revised and their
> corresponding new values.  I believe that if it hasn't changed, then it's
> not included in NewValues.
>
> Hopefully this might clear up some of your issues and then we can address
> any that remain.
> --
> Christopher A. Reed
> "The oxen are slow, but the earth is patient."
>