any suggestion is welcome…JSON Response – one substring not being recognized by my code

This is code that has been gleaned from "inline editing of the web grid" at

All code below works, the drop downs are properly populated, the grid displays as it should, the EDIT and SAVE work, the JSON write to CreateCalendarF works, the code inside there correctly changes the db, and the code there responds with the JSON string
exactly as I want it to.

The problem is that the calWId/WeekSelectionCal column in grid row that was updated does not reflect the change that was send over with the JSON response.  After I refresh the page it shows it correctly. All the other changes are being recognized

My problem is related to self inflicted confusion caused by different names for the same thing in two tables in the db.

calRecords  calr which is the main table  uses calWId

TimeSelections ts is the table that is being joined on JOIN TimeSelections ts ON calr.calWId = ts.WeekSelectionId

The last piece of code below is the JSON response retrieved from the Response in the browser.

    $(function () {

        $('.edit-calendar').on('click', function () {
            var tr = $(this).parents('tr:first');
            tr.find('.edit-mode, .display-mode').toggle();
        $('.save-calendar').on('click', function () {
            var tr = $(this).parents('tr:first');
            var ownerlocationid = $(this).prop('id');
            var location = tr.find('Location').val();
            var calwid = tr.find('#calWId').val();
            var caldid = tr.find('#calDId').val();
            var caloid = tr.find('#calOId').val();
            var qty = tr.find('#Qty').val();
            var c12 = tr.find('#C12').val();
            var c11 = tr.find('#C11').val();
            var c10 = tr.find('#C10').val();
            var c9 = tr.find('#C9').val();
            var c8 = tr.find('#C8').val();
            var c7 = tr.find('#C7').val();
            var c6 = tr.find('#C6').val();
            var c5 = tr.find('#C5').val();
            var c5min = tr.find('#C5min').val();
            var isactive = tr.find('#isActive').is(':checked');
                    { OwnerLocationId: ownerlocationid, Location: location, calWId: calwid, calDId: caldid, calOId: caloid, C12: c12, C11: c11, C10: c10, C9: c9, C8: c8, C7: c7, C6: c6, C5: c5, C5min: c5min, isActive: isactive },
                    function (cal) {
                        tr.find('#isactive-display').removeAttr("disabled").attr('checked', cal.isActive).attr('disabled', true);
                    }, "json");
            tr.find('.edit-mode, .display-mode').toggle();

grid.Column("Week", style: "col3", format:
                    <span id="calweek" class="display-mode">@item.WeekSelectionCal</span>
                    @Html.DropDownList("calWId", null, weekselections, item.calWId, new { @class = "edit-mode" })

var weekselections = db.Query("SELECT TOP (4) WeekSelectionId, WeekSelectionCal FROM TimeSelections")
        .Select(weekselection => new SelectListItem
            Value = weekselection.WeekSelectionId.ToString(),
            Text = weekselection.WeekSelectionCal


Leave a Reply