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

DataView Error on Update With DropDownList

P: n/a
AG
Hi,
ASP.NET 2.0 web app

I have a GridView utilizing template columns and bound to an
objectdatasource.
In the edit template of one column there is a dropdownlist bound to another
objectdatasource.
The dropdownlist displays the appropriate values when entering edit mode.
However when I try to update, I receive the following error.

Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control.

Here is the edititemtemplate
<EditItemTemplate>
<asp:DropDownList id="ddlNetDataType" runat="server" EnableViewState="False"
DataSourceID="odsNetDataTypes" SelectedValue='<%# Bind("NetDataType") %>'
DataTextField="NetDataType" DataValueField="NetDataType"></asp:DropDownList>
</EditItemTemplate>

Can anyone offer a fix?

TIA

AG
Email: discuss at adhdata dot com


Nov 15 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi AG,

This is a known issue. The fix is to turn on ViewState of the DropDownList:

#ASP.NET Forums - Problem of binding SelectedValue to DropDownList in
templated DetailsView
http://forums.asp.net/1004263/ShowPost.aspx
This is a problem that we're aware of. The issue occurs because your
dropdownlists have viewstate turned off but your detailsview has it
enabled. You can either enable viewstate for your dropdownlists or disable
it for your detailsview, and the error should go away.

Let me know if this helps. Thanks.

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.

Nov 16 '06 #2

P: n/a
AG
Walter,

Thanks for the response.

It probably makes no difference, but I am using a gridview, not a
detailsview. Sorry for the error in the subject of my post.
Turning on viewstate for the dropdownlist does prevent the error.
I would prefer to have it turned off.
I left viewstate turned on for the gridview because I am using paging and
thought that viewstate must be turned on in order to utilize paging. Is this
correct?

Are there plans to correct this issue?

--

AG
Email: discuss at adhdata dot com

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:LY**************@TK2MSFTNGXA01.phx.gbl...
Hi AG,

This is a known issue. The fix is to turn on ViewState of the
DropDownList:

#ASP.NET Forums - Problem of binding SelectedValue to DropDownList in
templated DetailsView
http://forums.asp.net/1004263/ShowPost.aspx
This is a problem that we're aware of. The issue occurs because your
dropdownlists have viewstate turned off but your detailsview has it
enabled. You can either enable viewstate for your dropdownlists or disable
it for your detailsview, and the error should go away.

Let me know if this helps. Thanks.

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.

Nov 16 '06 #3

P: n/a
Hi AG,

Regarding this case, apparently GridView and DetailsView all have the issue
as described in the forum post; thus for current moment using the
workaround of turning on ViewState of the DropDownList should be the only
way to get it working. Since this DropDownList only sends its ViewState
back to client browser when you're actually editing the row, it only
affects the page size in this case; it should not impact the page size when
user's viewing the GridView.

I'll go and check if there's any plan to fix it. Thank you for your
patience and understanding.

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

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Nov 17 '06 #4

P: n/a
AG
Thanks Walter.

I would still like to know if I must keep viewstate turned on for the
gridview.
As you stated, if I turn off viewstate for the gridview, then I can also
turn it off for the dropdownlist.
I do understand that the dropdownlist viewstate is only posted back when in
edit mode, but my actual case is that I am using a custom control that
inherits the gridview and provides an insert row to add a record. That row
also contains the same dropdownlist as my edit row, so viewstate is always a
factor.

So, the question at hand is:

If I turn off viewstate for the gridview, will I lose any functionality, or
will it simply need to be databound in each postback?
--

AG
Email: discuss at adhdata dot com

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:VQ*************@TK2MSFTNGXA01.phx.gbl...
Hi AG,

Regarding this case, apparently GridView and DetailsView all have the
issue
as described in the forum post; thus for current moment using the
workaround of turning on ViewState of the DropDownList should be the only
way to get it working. Since this DropDownList only sends its ViewState
back to client browser when you're actually editing the row, it only
affects the page size in this case; it should not impact the page size
when
user's viewing the GridView.

I'll go and check if there's any plan to fix it. Thank you for your
patience and understanding.

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

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Nov 17 '06 #5

P: n/a
Hi AG,

Turning off viewstate for the GridView will work if it's rebound in each
postback. However, there're some known issues which you should be aware of:

#Scott on Writing
http://scottonwriting.net/sowblog/posts/10054.aspx
WARNING: Concurrency Issue with ASP.NET 2.0 GridViews/DetailsView/FormViews
that Support Editing and/or Deleting and Whose View State is Disabled
Also, I've consulted with product team on the issue, they're actually aware
of this issue (as noted in the forum post I referenced in my first reply);
however, since it's a rather difficult one, it just takes more time to fix
it and unfortunately we cannot tell exactly when will it be fixed. We're
sorry for the inconvenience and appreciate for your understanding.

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

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Nov 20 '06 #6

P: n/a
AG
Thanks Walter,

For now, I will be leaving viewstate on for the gridview and dropdown.
I tried turning off viewstate for both and saw another problem.
The datasource for the gridview is a objectdatasource representating a
custom class that returns a dataview .
When I apply a filter to the objectdatasource and try to edit a row in the
gridview, the wrong row is edited.
A similar problem to the one you referenced. It seems that the gridview
references the full data source, and not just the filtered data when
viewstate is turned off.

--

AG
Email: discuss at adhdata dot com

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:ED**************@TK2MSFTNGXA01.phx.gbl...
Hi AG,

Turning off viewstate for the GridView will work if it's rebound in each
postback. However, there're some known issues which you should be aware
of:

#Scott on Writing
http://scottonwriting.net/sowblog/posts/10054.aspx
WARNING: Concurrency Issue with ASP.NET 2.0
GridViews/DetailsView/FormViews
that Support Editing and/or Deleting and Whose View State is Disabled
Also, I've consulted with product team on the issue, they're actually
aware
of this issue (as noted in the forum post I referenced in my first reply);
however, since it's a rather difficult one, it just takes more time to fix
it and unfortunately we cannot tell exactly when will it be fixed. We're
sorry for the inconvenience and appreciate for your understanding.

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

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Nov 20 '06 #7

P: n/a
Hi AG,

Thank you very much for your update.

I would also suggest turning on viewstate for both the GridView and
DropDownList at current moment.

Again, you're welcome to submit your feedback at
http://connect.microsoft.com/Main/co...ContentID=2220 which
is monitored by our product team directly.

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

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Nov 21 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.