You can do it using next code:
@Html.Sitecore().Rendering("{240A3624-8600-4A7B-8C07-5846A673F1F0}", new
{
DataSource = "{7CB5F3A9-F301-44C0-AB73-7A19837DA01C}"
})
First time is checking if the Rendering has a definition item and it set a datasource if it has a definition item.
After it verifies if has a Parameter in the .cshtml and if exist then it override the definition item.
Bellow code is used when you use .Rendering helper method
protected virtual Rendering GetRendering(string renderingType, object parameters, params string[] defaultValues)
{
Rendering rendering = new Rendering();
rendering.RenderingType = renderingType;
for (int i = 0; i < defaultValues.Length - 1; i += 2)
{
rendering[defaultValues[i]] = defaultValues[i + 1];
}
if (rendering.RenderingItem != null)
{
Item innerItem = rendering.RenderingItem.InnerItem;
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cacheable");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cache_Timeout");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cache_VaryByData");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cache_VaryByDevice");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cache_VaryByLogin");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "CacheKey");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cache_VaryByParameters");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cache_VaryByQueryString");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Cache_VaryByUser");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "DataSource");
this.CopyPropertyFromDefinitionItem(rendering, innerItem, "Model");
}
if (parameters != null)
{
Dictionary<string, object> properties = TypeHelper.GetProperties(parameters);
properties.Each(delegate(KeyValuePair<string, object> pair)
{
rendering.Properties[pair.Key] = pair.Value.ValueOrDefault((object o) => o.ToString());
});
}
return rendering;
}
I tried on Sitecore 8.2.1 and it works as expected for me.