1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / LibraryItemEdit Mapping field Bug.

LibraryItemEdit Mapping field Bug.

5 posts, 0 answered
  1. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    24 Sep 2009
    Link to this post

    Hi.
    On my LibraryItemEdit page i need to specify a use for a specific document. like :
    http://exchange.pixit.com:8000/img2.jpg
    And i click modify:
    http://exchange.pixit.com:8000/img1.jpg

    But when i set a value and i return on the LibraryItemEdit page i loose the value.
    code web.config:

    on metaFields  
     
    <add key="Libraries.Membre" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>  
     
    on libraryInfo  
     
    <add name="Document" title="Document Library" defaultExtenstions=".doc, .docx, .rtf, .txt, .pdf, .ppt, .pptx, .html, .xls, .xlsx" metaKeys="Author, Description, Extension, Name, Size, Category, Publication_Date,Journal,Pays,Membre,Navire">  
    </add> 
     
     


    code for the control : UserList.ascx

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserList.ascx.cs" Inherits="Sitefinity_UserControls_UserList" %> 
    <fieldset id="UserListWrapper">        
    <telerik:RadComboBox ID="Membre" runat="server" > 
        <Items> 
            <telerik:RadComboBoxItem Text="* User *" Value="* User *" /> 
        </Items>    
    </telerik:RadComboBox> 
    </fieldset>   

    code for UserList.ascx.cs

    using System;    
    using System.Collections.Generic;    
    using System.Linq;    
    using System.Web;    
    using System.Web.UI;    
    using System.Web.UI.WebControls;    
    using Telerik.Web.UI;  
    using System.Web.Security;  
     
    public partial class Sitefinity_UserControls_UserList : System.Web.UI.UserControl, ITextControl   
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            PopulateUser();  
        }  
     
        #region ITextControl Members  
        public string Text  
        {  
            get  
            { return Membre.SelectedValue; }  
            set  
            { Membre.SelectedValue = value; }  
        }  
     
        private void PopulateUser()  
        {  
            string[] AllUsers = Roles.GetUsersInRole("WebUser") ;  
            foreach (string roleUser in AllUsers)  
            {  
                Membre.Items.Add(new RadComboBoxItem(roleUser, roleUser));  
            }  
        }  
        #endregion  
    }  

    code on the LibraryItemEdit.ascx page

    <%@ Register src="~/Sitefinity/UserControls/UserList.ascx" tagname="UserList" tagprefix="uc1" %> 
    <asp:Label ID="Label15" AssociatedControlID="Membre" runat="server">  
    <asp:Literal ID="Literal28" runat="server" Text="Membre"></asp:Literal> 
    <em id="Em3" runat="server"></em></asp:Label> 
    <uc1:UserList ID="Membre" runat="server" /> 
    have you a solution ?
    Thk's
    Best regards
    Cyril
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 Sep 2009
    Link to this post
    Hi Cyril Wasem,

    You need to call GetMetaData method and return the correct value when the items is open for edit. Currently you just bind the RadComboBox control in each mode and the value is not associated with the view.

    Sample code:

    RadComboBoxItem item = new RadComboBoxItem(val, val); 
    combo.Items.Add(item); 
    // create a default text - the item does not have a user 
    if (item.Text != nullItem.Text) 
        string myMetaData= (e.Item.DataItem as IContent).GetMetaData("CustomMetaData").ToString(); 
        combo.SelectedValue = myMetaData; 

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    24 Sep 2009
    Link to this post
    Hi,

    Can you explain me where i put your sample code ?

    thk's
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 Sep 2009
    Link to this post
    Hello Cyril Wasem,

    You need to put the code under LibraryItemEdit.ascx.cs template ( create a code behind of the template or place your code inline) and find the RadComboBox inside ContentMetaFields control.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Cyril Wasem
    Cyril Wasem avatar
    20 posts
    Registered:
    04 Aug 2009
    24 Sep 2009
    Link to this post
    Ok fine.
    thk's for all.
    Cyril
Register for webinar
5 posts, 0 answered