mardi 2 juillet 2019

Grid.MVC send selected columns data to Controller

I want to send multiple selected column values to controller. I don't have issues in sending one column data to controller but having trouble sending more than one column data.

View:

@using (Html.BeginForm("GridView", "Home", FormMethod.Post))
{
    @Html.Grid(Model).Columns(columns =>
    {
        columns.Add()
            .Titled("<input type=checkbox class=ckbCheckAll />")
            .Encoded(false)
            .Sanitized(false)
            .SetWidth(10)
            .RenderValueAs(c => Html.CheckBox("assignChkBx", false, new { @class = "checkBoxClass", value = c.AccountNumber})).SetWidth(10);
        //.RenderValueAs(c => Html.CheckBox("checked", false, new {@class = "checkBoxClass"})).SetWidth(10);
        columns.Add(c => c.AccountNumber).Titled("ACCOUNTNUM").SetWidth(20);
    }).WithPaging(8);

Controller:

[HttpPost]
        public ActionResult GridView(FormCollection form)
    {
        SelectedListOfClaimants slc = new SelectedListOfClaimants();
        var checkbox = form.GetValues("assignChkBx");

        }

In the view where I have value = c.AccountNumber (One of my columns), I need to add two more columns and send all three columns data to my controller.




Aucun commentaire:

Enregistrer un commentaire