|
|
||||||
|
#1
|
|
|
|
|
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 |
|
|
|
#2
|
|
|
|
|
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/p/906115/1004263.aspx#1004263 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 (wawang, 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/en-us/subs.../aa948874.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
|
#3
|
|
|
|
|
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? |
|
#4
|
|
|
|
|
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 (wawang, 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. |
|
#5
|
|
|
|
|
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? |
|
#6
|
|
|
|
|
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 (wawang, 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. |
|
#7
|
|
|
|
|
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. |
|
#8
|
|
|
|
|
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 [url down] which is monitored by our product team directly. Regards, Walter Wang (wawang, 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. |
|
|
| Similar Threads | |
| Thread | Thread Starter |
| Help with dropdownlist - Dataview 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... |
glbdev |
| Update Sub Form Dataview on Keyup? I have a form with a couple of unbound fields that I want to use to filter a subform/dataview on it by the value you type in the fields. The query on the dataview uses... |
Barkster |
| dataview update problems Hi, Here's a short description of a problem that took me a couple of days to bypass (not solve): I update a table thru a dataview (or dataset, no difference in behavior for... |
Tony Papadimitriou |
| DataSet vs. DataView - How to update? I have a WinForms app that builds a DataSet from an XML file. The DataSet is wrapped in a DataView and bound to various controls through which users will make changes to the... |
deko |
| dataView & dataAdapter.update If i delete e record through the dataView ,the record is deleted in the underlying dataset, but when calling the dataadapter.udate method the database is not... |
Sagaert Johan |
|
Privacy Policy | All times are GMT. The time now is 04:55 PM.
|
|
|