I'm having trouble figuring out how to create a DropDownList in my existing WebGrid. I'm retrieving the following data from my Controller:

List items 0-2 are filled with "KeyA":

enter image description here

And List items 3-5 are filled with "KeyOther":

enter image description here

These have not yet any combination with eachother but I'm trying to create a WebGrid with the list items of type "KeyA" on the first column presented in labels and the list items of type "KeyB" in the second column presented as DropDownLists for each list item of "KeyA". Look example:

enter image description here

I cant figure out how to do this, this is what I got now:

enter image description here

With the following code:

@{
                if (Model != null && Model.Count() > 0)
                {
                    var grid = new WebGrid(canPage: true, rowsPerPage: 10);
                    grid.Bind(source: Model, rowCount: 0, autoSortAndPage: false);

                    <div class="row" id="content2">
                        <div class="col-lg-12 d-flex align-items-stretch">

                            @grid.Table(tableStyle: "table table-responsive table-striped table-bordered",
                                columns: grid.Columns(
                                grid.Column(columnName: "KeyA", header: "KeysA", format:@<text><div class="" data-id="@item.KeyA" data-propertyname="KeyA">@item.KeyA</div></text>),
                                grid.Column(columnName: "KeyOther", header: "KeysOther", format:@<text><div class="" data-id="@item.KeyOther" data-propertyname="KeyB">@item.KeyOther</div></text>)
                                    ))
                        </div>
                        <!--Pagerlist for webgrid-->
                        <div class="col-lg-12 d-flex align-items-stretch">
                            @grid.PagerList(mode: WebGridPagerModes.All, paginationStyle: "pagination pagination-small pagination-right")
                        </div>

                        @Html.Hidden("dir", grid.SortDirection)
                        @Html.Hidden("col", grid.SortColumn)
                    </div>
                }
}

Hope somebody can help me!

Thanks in advance!

Related posts

Recent Viewed