use values of control inline code
i need to fill dropdownlist and use its selected value in inline code to fill href of menu items .
example : i have DropCountry and fill it from DB then i get the location of client and set the selectedindex with this value , so i want to set href of menuitem with Query string of CountryID taken from dropCountry.selectedValue.
but he compile the inline Code before Codebehind :S
"Details.aspx?AdID=<%# DataBinder.Eval(Container.DataItem, "AdID")%>&CatID=<% Response.Write(GetIDCatFromQueryString()); %>&Country=<% i need to get value here %&g开发者_JAVA百科t;"
Here is my solution for you:
I suspect that you are binding the menu item with datasource so the databinding of the menuitme happens before the page load where you have set the drop down list items and selected one of them so i suggest that in your page load, make the steps as following:
- Fill the drop down list with data
- Select the item from the drop down list
- Make the menu item binding
OR
You can fill the drop down list and select an item in the Page_OnInt event.
In Both cases you have to update you code by adding <%# YourDropDownList.SelectedValue %>
精彩评论