More in this section

Forums / Developing with Sitefinity / ViewModeControl + DataItemId

ViewModeControl + DataItemId

5 posts, 1 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    04 Feb 2010
    Link to this post
    Hi all,

    I'm trying to build an Intra-Site module for my SF project.
    I was wondering if the DataItemId must be a Guid?

    The ID's from my database are integers, but to use the DataItemId property from the ViewModeControl, I have to use Guid's, what I don't prefer.

    Are there any other options?

    Thanks,
    Daniel
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Feb 2010
    Link to this post
    Hello Daniel,

    The DataItemId should be GUID. This value is later assigned as contentItem ID and then persisted to the database.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    04 Feb 2010
    Link to this post
    Hi Ivan,

    Thanks for your reply.
    How should I then pass the key (integer) from one view to another?

    I use this Contacts Intra-Module example which uses an UserControl to edit and add new contacts.
    There it works like this:

    using System;
    using Telerik.Cms.Web.UI;
    using Telerik.Samples.Contacts;
      
    public partial class Modules_Contacts_Views_Backend_ItemEditView : ViewModeUserControl<ContactItemsView>
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            backButton.NavigateUrl = CreateHostViewCommand("ItemListView", null, null);
            contactEditor.ListCommand = CreateHostViewCommand("ItemListView", null, null);
            contactEditor.ContactId = this.DataItemId; // GUID, but need integer?
            contactEditor.Manager = this.Host.Host.Manager;
        }
    }

    Or should I give the ID through the QueryString? Don't like that...

    -Daniel-
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Feb 2010
    Link to this post
    Hi Daniel,

    Please take a look at How to navigate among Views: How do I pass parameters between Views

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
    Answered
  5. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    04 Feb 2010
    Link to this post
    Hi Ivan,

    Don't know if this is the right way, but it works also:

    edit.NavigateUrl = CreateHostViewCommand("ItemEditView", familyRow.FamilyId.ToString(), string.Empty);

    So, problem solved :)

    -Daniel-
Register for webinar
5 posts, 1 answered