I am using Grid.MVC(https://gridmvc.codeplex.com/) and I need to render a grid and CRUD for the grid in the same view.
@model IEnumerable<Grid.Models.Catagory>
...
...
@Html.Grid(Model).Columns(columns =>
{
columns.Add()
.Encoded(false)
.Sanitized(false)
.Titled("CatagoryName").RenderValueAs(o => RenderCatagoryName("CatagoryName", o.CatagoryName));
columns.Add()
.Encoded(false)
.Sanitized(false)
.Titled("Color").RenderValueAs(o => RenderCatagoryName("Color", o.Color));
columns.Add()
.Encoded(false)
.Sanitized(false)
.Titled("Print Template").RenderValueAs(o => RenderCatagoryName("Print Template", o.PrintTemplate));
}
My controller
public ActionResult Index()
{
return View(clients);
}
This works fine, but when I need to do an insert in that same view, I am unable to use the same model since it is an IEnumerable type.
--Insert values--
//couldn't use the model for insert directly since it is a list type
@Html.LabelFor(m => m.)
@Html.TextBoxFor(m => m., new { maxlength = 50 })
My ViewModel
public class Catagory
{
public int CatagoryID { get; set; }
public string CatagoryName { get; set; }
public string Color { get; set; }
public string PrintTemplate { get; set; }
public string Language { get; set; }
}
Is there any way to use the same view for both the Grid.MVC and insert operations