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

Forums / Developing with Sitefinity / Dropdown for a metaField

Dropdown for a metaField

7 posts, 0 answered
  1. Jesse
    Jesse avatar
    21 posts
    Registered:
    28 Nov 2007
    16 Sep 2008
    Link to this post
    I've already got a module copied out from Generic Content, named it "articles" and I'm attempting to add in a drop down for permissions.  In the webconfig, I've added this.

    <add key="Articles.Level" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" />

    In the ControlPanelInsert within the editMetaFields, I've slapped in this

    <asp:Label ID="Label5" AssociatedControlID="Level" runat="server" Text="Permission" />
    <asp:DropDownList ID="Level" runat="server">
    <asp:ListItem Text="Level 2" Value="2" />
    <asp:ListItem Text="Level 3" Value="3" />
    <asp:ListItem Text="Level 4" Value="4" />
    <asp:ListItem Text="Level 5" Value="5" />
    </asp:DropDownList>


    Displays just fine just before description (which is where I want it to go), doesn't throw an error or anything when I create a new item, no problem there.  On the code behind of the display control (to be dragged out to the page for the world to see) -- I put this code on the page load...

    ContentManager manager = new ContentManager();
    IDictionary<string, IMetaInfo> keys = manager.GetMetaKeys(Content as IContent);

    and again, no errors, but only comes back with 4 keys instead of the expected 5.  What am I missing?
  2. Jesse
    Jesse avatar
    21 posts
    Registered:
    28 Nov 2007
    16 Sep 2008
    Link to this post
    suppliment info - when I save the stuff on the admin side, under "details" the info shows up that I entered.
  3. Jesse
    Jesse avatar
    21 posts
    Registered:
    28 Nov 2007
    16 Sep 2008
    Link to this post
    and here's the fix -- since there's multiple providers, you have to tell the manager were to go get it (duh).

    ContentManager manager = new ContentManager(ProviderName);
    IDictionary<string, IMetaInfo> keys = manager.GetMetaKeys(Content as IContent);

  4. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    16 Sep 2008
    Link to this post
    Hi Jesse,

    I'm glad you got it fixed!

    I was toying with your issue when you posted your fix.  I hadn't yet figured out the fix.  Thanks for reporting back & helping me & others.

    Gabe Sumner

  5. Jesse
    Jesse avatar
    21 posts
    Registered:
    28 Nov 2007
    17 Sep 2008
    Link to this post
    Hey Gabe, maybe you can help me take this one step further -- I'm trying to get the data out now (who'd a though?) and  I've got my 6 keys, how do I get the data out? 

    the keys.values are IMetaInfo objects, verifies the data I put in the web.config works, but doesn't have the info.

    MetaData looks promissing, but no real method to pull the data out.  Ideas?
  6. Jesse
    Jesse avatar
    21 posts
    Registered:
    28 Nov 2007
    17 Sep 2008
    Link to this post
    heh, figured it out again!  

    Guid contentId = GenericContent1.ContentID;
    IContent content = manager.GetContent(contentId);
    string key = contentItem.GetMetaData(key).ToString();

  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Sep 2008
    Link to this post
    Hello Jesse,

    We are glad that you got it working :)

    All the best,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
7 posts, 0 answered