Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

c# - Problem displaying a webgrid in MVC ASP NET

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

enter image description here

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...