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

2 posts, 0 answers
  1. Jim
    Jim avatar
    2 posts
    Member since:
    Apr 2007

    Posted 19 Nov 2009 Link to this post

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

    Any answers ?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Nov 2009 Link to this post

    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.
Back to Top