I am new to RadPanelBar. I want to dynamically bind not just menu text / structure but also images. Is there any way to do that?
Here is my test code modified from sample:
Here is my test code modified from sample:
protected void Page_Load(object sender, EventArgs e) | |
{ | |
if(!this.IsPostBack) | |
{ | |
uxLFMenuBarML.DataTextField = "Text"; | |
uxLFMenuBarML.DataFieldID = "ID"; | |
uxLFMenuBarML.DataFieldParentID = "ParentID"; | |
uxLFMenuBarML.DataSource = GenerateSiteData(); | |
uxLFMenuBarML.DataBind(); | |
} | |
} | |
private ArrayList GenerateSiteData() | |
{ | |
ArrayList siteData = new ArrayList(); | |
siteData.Add(new LFMenuBarDataItem(1, null, "All Sites","~/images/1.jpg")); | |
siteData.Add(new LFMenuBarDataItem(2, 1, "Search Engines", "~/images/2.jpg")); | |
siteData.Add(new LFMenuBarDataItem(3, 1, "News Sites", "~/images/3.jpg")); | |
siteData.Add(new LFMenuBarDataItem(4, 2, "Yahoo", "~/images/4.jpg")); | |
siteData.Add(new LFMenuBarDataItem(5, 2, "MSN", "~/images/5.jpg")); | |
siteData.Add(new LFMenuBarDataItem(6, 2, "Google", "~/images/6.jpg")); | |
siteData.Add(new LFMenuBarDataItem(7, 3, "CNN", "~/images/7.jpg")); | |
siteData.Add(new LFMenuBarDataItem(8, 3, "BBC", "~/images/8.jpg")); | |
siteData.Add(new LFMenuBarDataItem(9, 3, "FOX", "~/images/9.jpg")); | |
return siteData; | |
} | |
public class LFMenuBarDataItem | |
{ | |
private string _text; | |
private int _id; | |
private int? _parentId; | |
private string _imageUrl; | |
public string Text | |
{ | |
get { return _text; } | |
set { _text = value; } | |
} | |
public int ID | |
{ | |
get { return _id; } | |
set { _id = value; } | |
} | |
public int? ParentID | |
{ | |
get { return _parentId; } | |
set { _parentId = value; } | |
} | |
public string ImageUrl | |
{ | |
get { return _imageUrl; } | |
set { _imageUrl = value; } | |
} | |
public LFMenuBarDataItem(int id, int? parentId, string text, string imageUrl) | |
{ | |
_id = id; | |
_parentId = parentId; | |
_text = text; | |
_imageUrl = imageUrl; | |
} | |
} |