Dear Sir/Madam,
I have an issue regarding pass parameters into cshtml page.
I have a DataTablesModel in the configure page, this table have many columns including button Edit, when click on this button, it will call Edit function and redirect to Edit page. I want to get appropriately Id to do in Edit function, but Id value is always 0.
How can I get the Id value in Edit function? please help me
Thank & Best Regards,
#Configure.cshtml
....
<div class="panel panel-default">
<div class="panel-body">
@await Html.PartialAsync("Table", new DataTablesModel
{
Name = "grid",
UrlRead = new DataUrl("List", "Custom",null),
Paging = false,
ColumnCollection = new List<ColumnProperty>
{
new ColumnProperty(nameof(CustomModel.Id))
{
Title = "ID",
Width ="300"
},
new ColumnProperty(nameof(CustomModel.Id))
{
Title = T("Admin.Common.Edit").Text,
Width = "100",
Render = new RenderButtonEdit(new DataUrl("~/Admin/Custom/Edit/"))
}
}
})
</div>
</div>
#CustomControler
namespace Nop.Plugin.Widgets.Custom.Controllers
{
[Area(AreaNames.Admin)]
[AuthorizeAdmin]
[AutoValidateAntiforgeryToken]
public class CustomController : BasePluginController
{
public IActionResult Configure()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
return AccessDeniedView();
...
}
[HttpPost]
public IActionResult Configure(CustomModel model)
{
if (!ModelState.IsValid)
{
return Configure();
}
...
}
public virtual IActionResult List(CustomSearchModel searchModel)
{
...
return json(model);
}
public virtual IActionResult Edit(int Id)
{
var model = new CustomModel();
model.Id = Id; //Id is always 0
return View("~/Plugins/Custom/Views/Edit.cshtml", model);
}
}
}