This is a migrated thread and some comments may be shown as answers.

How to populate Radmenus (image only) with image Urls stored in database

1 Answer 81 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 19 Nov 2009, 03:57 PM
How to populate Radmenus (image only) with image Urls stored in database ?

Any answers ?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Nov 2009, 12:45 PM
Hello Veenu,

Here the code that I tried in order to show images only for RadMenuItems by setting the ImageUrl in ItemDataBound event of RadMenu.

aspx:
 
<telerik:RadMenu ID="RadMenu1" runat="server" DataSourceID="SqlDataSource1" DataFieldID="Field1" OnItemDataBound="RadMenu1_ItemDataBound"
</telerik:RadMenu> 
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
        SelectCommand="SELECT * FROM [MyTable]"
</asp:SqlDataSource> 

cs:
 
    protected void RadMenu1_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e) 
    { 
        RadMenuItem item = (RadMenuItem)e.Item; 
        DataRowView row = (DataRowView)item.DataItem; 
        item.Text = ""
        item.ImageUrl = row["url"].ToString(); // Set the ImageUrl, here url is the fieldname 
    } 

-Shinu.
Tags
Menu
Asked by
Jim
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or