0

I am having issues when passing Guid as the data source for edit Frame.

When I populate the Guid directly it works fine but while binding it from model am getting an error message

Code:

@using Sitecore.Mvc.Extensions
@{
    var itemid = @Model.PropertyGuid;
}

@foreach (Sitecore.Data.Items.Item listItem in @Model.DiningServiceItem)
{
    using (Html.EditFrame("@itemid", "DininglEvents", null, null, null, null))
    {
        <li> @listItem.Name</li>
    }
}

Error message:

An error occurred. [Log message: Could not get item with id: from database:master]

Any idea how I can fix this?

Thanks

3
  • From what I see, the problem is that you have quote marks around @itemid, am I right?
    – Marek Musielak
    Commented Apr 3, 2018 at 17:36
  • when i remove quotes am getting this error Rendering Controller: Dining. Action: index: An unhandled exception occurred Commented Apr 3, 2018 at 17:39
  • check the GUID format Commented Apr 3, 2018 at 17:44

1 Answer 1

3

According to the docs you can pass the datasource argument in one of the following formats:

  • /sitecore/content/Home
  • {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}
  • RenderingContext.Current.ContextItem.ID.ToString()
  • RenderingContext.Current.PageContext.Item.ID.ToString()
  • Html.Sitecore().CurrentRendering.DataSource To use this format, you
  • must create a Data Source field in a rendering (Presentation, Details, Controls, Your Rendering).

https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/using_editframes

What format is your @itemid guid in?

Perhaps try:

.ToString() 

on your Item ID.

2
  • 1
    working code using (Html.EditFrame(@itemid.ToString(), "DininglEvents", null, null, null, null)) Commented Apr 3, 2018 at 17:44
  • Great. Just .ToString() was needed then? Commented Apr 3, 2018 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.