Programmly select menuitem?

R

rockdale

Hi, all

I have an asp:menu in my master page. on my content page I have the
following code to programmly select the mainmenu.

Menu mMain = (Menu)this.Master.FindControl("menuMain");
mMain.Items[0].Selected = true;

It works fine.

The problem is, the datasource of this mainmenu from my database based
on the login confidential, so different user will has a different set
of mainmenu - which means the index of menu is different.

Can I set the selected based on the menu item text or can I find the
index of menuitem based on menuitem text?

Thanks a lot
-rockdale
 
R

rockdale

Never mind.

I asked a silly question.

foreach(MenuItem itm in pmenu.Items){
if (itm.Text.ToString().Equals(ptext))
{
itm.Selected = true;
return;
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top