By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,356 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,356 IT Pros & Developers. It's quick & easy.

Grid View and ODS

P: n/a
I have a Grid View and associated Object Data Source control. The ODS
interface with a custom data source that returns a List<MyEntity>.

I am only referencing some of the columns on the GridView. When editing a
row within the Grid View, the columns that are not referenced, are being set
to null. Is this by design or am I missing something else somewhere?

Apr 13 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Apr 13, 6:43 pm, "Andrew Robinson" <nem...@nospam.nospamwrote:
I have a Grid View and associated Object Data Source control. The ODS
interface with a custom data source that returns a List<MyEntity>.

I am only referencing some of the columns on the GridView. When editing a
row within the Grid View, the columns that are not referenced, are being set
to null. Is this by design or am I missing something else somewhere?
I usually reference all of the columns but set some of them to
invisible. This way they are available in the delete/insert/update
events.
Also make sure you set the 'Set empty values to null' property for
each column to false or empty fields are set to null. Another caveat
to look out for if you are formating the values in display mode. Make
sure you use the Eval and not the Bind method for the data binding.
Otherwise on Delete it tries to convert the formatted values back into
the fields of the objectdatacontrol. This can cause exceptions for
certain currency and numeric formatting.

Apr 14 '07 #2

P: n/a
Hi Andrew,

What you're seeing is by design behavior. When a data record is bound to a
row in the GridView, only those referenced fields' values are kept in the
ViewState. To keep them when updating, you will have to bind all the fields
to the GridView and you can selectively hide those columns that you don't
want to show on the page. Another way is to use the primary key to find the
record from your data access layer (or cache) again.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 16 '07 #3

P: n/a
Kind of what I expected. Thanks,

-Andy

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:7J****************@TK2MSFTNGHUB02.phx.gbl...
Hi Andrew,

What you're seeing is by design behavior. When a data record is bound to a
row in the GridView, only those referenced fields' values are kept in the
ViewState. To keep them when updating, you will have to bind all the
fields
to the GridView and you can selectively hide those columns that you don't
want to show on the page. Another way is to use the primary key to find
the
record from your data access layer (or cache) again.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.
Apr 16 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.