views:

231

answers:

3

Below is a some sample code I am trying to update. The client would like to make the menu item text an AppSetting Value. I have been able to setup the appsettings and the function to implement it. But I am getting an error on my Bind code and wondering if anyone see something I missed.

Is it as easy as setting an ID tag for the MenuItem? When I try to use ID it is not reconizable by visual studio in the intellisense.

Error -> The MenuItem control with a two-way databinding to field OUEntity must have an ID.


<asp:MenuItem PopOutImageUrl="" Text="Administration" Selectable="false">
 <asp:MenuItem NavigateUrl="" Text="" ></asp:MenuItem>
 <asp:MenuItem NavigateUrl="" Text="" ></asp:MenuItem>
 <asp:MenuItem NavigateUrl="" Text=""></asp:MenuItem>                
 <asp:MenuItem NavigateUrl="" Text='<%# Bind("OUEntity") %>'></asp:MenuItem>
 <asp:MenuItem NavigateUrl="" Text="" ></asp:MenuItem>
 <asp:MenuItem NavigateUrl="" Text="" ></asp:MenuItem>                                              
 <asp:MenuItem NavigateUrl="" Text=""  ></asp:MenuItem>
 <asp:MenuItem NavigateUrl="" Text="" ></asp:MenuItem>
 <asp:MenuItem NavigateUrl="" Text="" ></asp:MenuItem>
 <asp:MenuItem NavigateUrl="" Text="" ></asp:MenuItem>
</asp:MenuItem>
+1  A: 

You are going to need to replace what you have with something like the following <%= ConfigurationManager.AppSettings["OUEntity"] %>

runxc1 Bret Ferrier
Hmm... Now there is nothing being passed to the menu item for the text. There is a blank spot where the text should appear. So I don't think the eval is working. I wonder if I might need to do a little in the code behind to make sure it is filled.What do you think?
JPJedi
The only time that you should use the Eval is if you are using DataBinding. Say for example you have a asp:Repeater and the server tag is found inside the asp:Repeater.
runxc1 Bret Ferrier
A: 

Try using Eval (one way binding) instead of Bind (2 way binding). I also assume you would be refering ConfigurationManager.AppSettings while doing the binding.

That said, I had to do it on the code behind based on the url. But I don't recall if it was the asp.net Menu, or a third party one.

eglasius
A: 

Hmm... Now there is nothing being passed to the menu item for the text. There is a blank spot where the text should appear. So I don't think the eval is working. I wonder if I might need to do a little in the code behind to make sure it is filled.

What do you think?

JPJedi
It was a typo. After taking the night off and looking at it the next morning I noticed the typo on the code behind.
JPJedi