Hi, I am creating Dynamic bulletList in asp.net. It gathers the data from the database and creates a list of objects in a list format. think loop through the list and creates a dynamic listitem which I bind to a control on the page.
My problem is that I set the value to the url and text to the name of the link.
But… The value seems to be ignored and the text seems to be converted to a link instead of the value. I tried putting a url in the text part of the control but the anchor tage gets converted. I can decode it but surely there is an easier way to set the text and value of the link dynamically.
my code…
public static List<ListItem> CategoryMenuBuilder(List<Category> CategoryList)
{
string querId = "CatId=";
List<ListItem> CategoryMenu = new List<ListItem>();
foreach(Category menuItem in CategoryList)
{
ListItem newItem = new ListItem();
newItem.Text = menuItem._categoryName;
//newItem.Value = "product.aspx?" + querId + menuItem._categoryId;
newItem.Value = "http://www.google.co.uk";
CategoryMenu.Add(newItem);
}
return CategoryMenu;
I then bind it to a control here…
CategoryMenu.DataSource = Category.CategoryMenuBuilder(Category.CategoryDbBuilder());
CategoryMenu.DataBind();
<asp:BulletedList ID="CategoryMenu" runat="server" DisplayMode="HyperLink">
</asp:BulletedList>