I need populate two DropDownList's from values obtained from a database table using MySql database and view model using ASP NET MVC.
After populate a DropDownList's I need filter WebGrid using the value selected on single DropDownList.
With this controller part
public ActionResult RecoveryAll()
{
PersonModel model = new PersonModel();
model.Dates_List = PopulateDates(null); //First DDL
model.Ticket_List = PopulateTkt(null); //Second DDL
return View(model);
}
[HttpPost]
public ActionResult RecoveryAll(string country)
{
PersonModel model = PopulateModel(country);
return View(model);
}
private static PersonModel PopulateModel(string country)
{
PersonModel model = new PersonModel();
return model;
}
on return I have
Now I need displaying the WebGrid and edit the view to
@webGrid.GetHtml(
htmlAttributes: new { @id = "WebGrid", @class = "Grid" },
columns: webGrid.Columns(
webGrid.Column("CustomerID", "Customer Id"),
webGrid.Column("ContactName", "Customer Name"),
webGrid.Column("City", "City"),
webGrid.Column("Country", "Country")))
But how to do edit the controller for displaying WebGrid?
Because the debug on visual studio 2019 now I have this error
You must bind a data source to be able to do this
Help me to do it.
question from:
https://stackoverflow.com/questions/65921928/problem-displaying-a-webgrid-in-mvc-asp-net 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…