473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DataView Error on Update With DropDownList

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
7 4518
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: wackyphill | last post by:
I loop thru a Filtered DataView and update several of the rows in the loop. The problem is once a ropw gets altered the DataView's Count Seems to be altered causing me to access rows that it...
0
by: Shane O. Pinnell | last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a datagrid populated from a dataset. I have a...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
4
by: James | last post by:
Basically I have a DataGrid that I'm binding to the results of a stored procedure call. The recordset is fairly small. Initially I'm creating a DataSet from the results and binding it. There's a...
3
by: Elmo Watson | last post by:
I previously had a project working, in which the Gridview was populated by a DataSet - then, with a DropDownlist in one of the columns, using the OnrowDataBound event, to populate the DDL with the...
0
by: shahDeveloper | last post by:
i have created a number of combo boxes according to my need.no i want to save the changes when any one click update button,but here the control did not find by findcontrol function. Dim i, j, totc...
1
by: glbdev | last post by:
I searched around but cannot find an answer to this problem, if there is an answer. I have a DataView and a dropdownlist both on the same page. The dropdown list is a bound list of companies. ...
0
by: AlDave | last post by:
What I'm trying display is after the user chooses the product (1st category) from a dropdown, then the dataview will display; The category any reports under that subcategory any...
6
by: Ahmedhussain | last post by:
Hi there, I m doing work on a gridview and Im getting an error: A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.