Hi
I'm having trouble with a dropdownlist that is throwing an error.
I am populating the DDL with sqldatasource
When I load the page up and try to change the selection it throws this error:
Can't select a disabled or unselectable menu item.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Can't select a disabled or unselectable menu item.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Can't select a disabled or unselectable menu item.]
System.Web.UI.WebControls.Menu.SetSelectedItem(MenuItem node) +1236789
System.Web.UI.WebControls.MenuItem.NotifyOwnerSelected() +113
System.Web.UI.WebControls.MenuItem.System.Web.UI.IStateManager.LoadViewState(Object state) +60
System.Web.UI.WebControls.MenuItemCollection.System.Web.UI.IStateManager.LoadViewState(Object state) +574
System.Web.UI.WebControls.MenuItem.System.Web.UI.IStateManager.LoadViewState(Object state) +90
System.Web.UI.WebControls.MenuItemCollection.System.Web.UI.IStateManager.LoadViewState(Object state) +574
System.Web.UI.WebControls.Menu.LoadViewState(Object state) +440
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +218
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +218
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +218
System.Web.UI.Page.LoadAllState() +312
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661
Thanks for your quick reply, here is my dropdownlist and datasource:
<asp:DropDownList ID="ddlTowerTypeSpec2" runat="server" AutoPostBack="true"
DataSourceID="dsTowerSpecType2" DataTextField="Value"
DataValueField="UniqueID">
</asp:DropDownList>
<asp:SqlDataSource ID="dsTowerSpecType2" runat="server"
ConnectionString="<%$ ConnectionStrings:Conn_GADB %>"
SelectCommand="SELECT - 1 AS UniqueID, '' AS Value, 1 AS sortOrder UNION SELECT tTowerTypeSpecs.UniqueID, SpecLookup.Value + ' ' + TypeLookup.Value AS Value, 2 AS sortOrder FROM tTowerTypeSpecs INNER JOIN tLookups AS SpecLookup ON tTowerTypeSpecs.SpecL_ID = SpecLookup.UniqueID INNER JOIN tLookups AS TypeLookup ON tTowerTypeSpecs.TypeL_ID = TypeLookup.UniqueID ORDER BY sortOrder, Value">
</asp:SqlDataSource>
Thanks for looking into it, but I've discovered what the problem was.
I have a navigation menu which is databound to my site map.
I added some code to the master page which went through the menu items in the navigation menu and set them to non-selectable.
Either I coded it incorrectly or there is a bug, but as well as making the navigation menu unselectable, it also made the drop downlist items in the page unselectable too.
Here is the code I had originally:
foreach (MenuItem homeMI in navMenu.Items)
{
foreach (MenuItem childMI in homeMI.ChildItems)
{
if (childMI.Text == "Foundation Design" || childMI.Text == "Contract Admin")
{
childMI.Selectable = false;
}
}
}
and here is the code I used to solve it:
int HomeParentMenu = 0;
int FoundationDesignMenu = 0;
int ContractMenu = 2;
navMenu.Items[HomeParentMenu].ChildItems[FoundationDesignMenu].NavigateUrl = "";
navMenu.Items[HomeParentMenu].ChildItems[ContractMenu].NavigateUrl = "";
Thanks again.
Marked as answer by bbcompent1 on May 04, 2012 02:12 PM
piess
Member
2 Points
7 Posts
DropDownList - Can't select a disabled or unselectable menu item.
May 03, 2012 01:53 PM|LINK
Hi
I'm having trouble with a dropdownlist that is throwing an error.
I am populating the DDL with sqldatasource
When I load the page up and try to change the selection it throws this error:
Please can you help me solve this.
DROPDOWNList
bbcompent1
All-Star
33000 Points
8513 Posts
Moderator
Re: DropDownList - Can't select a disabled or unselectable menu item.
May 03, 2012 01:58 PM|LINK
I think I know what might be wrong but to know for sure, I need to see your code for the dropdown so please post it. Thanks!
piess
Member
2 Points
7 Posts
Re: DropDownList - Can't select a disabled or unselectable menu item.
May 03, 2012 02:00 PM|LINK
Thanks for your quick reply, here is my dropdownlist and datasource:
<asp:DropDownList ID="ddlTowerTypeSpec2" runat="server" AutoPostBack="true" DataSourceID="dsTowerSpecType2" DataTextField="Value" DataValueField="UniqueID"> </asp:DropDownList> <asp:SqlDataSource ID="dsTowerSpecType2" runat="server" ConnectionString="<%$ ConnectionStrings:Conn_GADB %>" SelectCommand="SELECT - 1 AS UniqueID, '' AS Value, 1 AS sortOrder UNION SELECT tTowerTypeSpecs.UniqueID, SpecLookup.Value + ' ' + TypeLookup.Value AS Value, 2 AS sortOrder FROM tTowerTypeSpecs INNER JOIN tLookups AS SpecLookup ON tTowerTypeSpecs.SpecL_ID = SpecLookup.UniqueID INNER JOIN tLookups AS TypeLookup ON tTowerTypeSpecs.TypeL_ID = TypeLookup.UniqueID ORDER BY sortOrder, Value"> </asp:SqlDataSource>piess
Member
2 Points
7 Posts
Re: DropDownList - Can't select a disabled or unselectable menu item.
May 03, 2012 02:15 PM|LINK
Could it be a problem with my page?
I have just put this drop down list on the page and even it came up with the same error.
<asp:DropDownList ID="ddl2" runat="server" AutoPostBack="true"> <asp:ListItem Enabled="true" Text="Selection 1" Value="1"></asp:ListItem> <asp:ListItem Enabled="true" Text="Selection 2" Value="2"></asp:ListItem> <asp:ListItem Enabled="true" Text="Selection 3" Value="3"></asp:ListItem> </asp:DropDownList>piess
Member
2 Points
7 Posts
Re: DropDownList - Can't select a disabled or unselectable menu item.
May 03, 2012 02:44 PM|LINK
Thanks for looking into it, but I've discovered what the problem was.
I have a navigation menu which is databound to my site map.
I added some code to the master page which went through the menu items in the navigation menu and set them to non-selectable.
Either I coded it incorrectly or there is a bug, but as well as making the navigation menu unselectable, it also made the drop downlist items in the page unselectable too.
Here is the code I had originally:
foreach (MenuItem homeMI in navMenu.Items) { foreach (MenuItem childMI in homeMI.ChildItems) { if (childMI.Text == "Foundation Design" || childMI.Text == "Contract Admin") { childMI.Selectable = false; } } }and here is the code I used to solve it:
Thanks again.