There is a Controller rendering and in its
Data source field, I gave the path of the datasource item.
[ The datasource item's path is set in the rendering itself and not in the presentation details. ]
I can get the datasource item in code like this
string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;
But the same is not working for a View rendering. The code returns empty value.
The View rendering is loaded from the layout's cshtml like this
@Html.Sitecore().Rendering("<path of the rendering>")
Tried with and without assigning a Sitecore model to the rendering.
Using Sitecore 8.2