Note that there are some explanatory texts on larger screens.

plurals
  1. POVariable unable to show on page
    primarykey
    data
    text
    <p>I'm unable to get the string of WebGrid.SortColumn on my webpage. When I'm debugging my Razor page the value is set as shown on the image below. So just before the View is send to my browser something changes from this variable so it seems empty. I need this property to be printed inside the hidden field to add the arrows for the sorting function, however all options I can think of didn't work to get the value inside my page.</p> <p>This code is used inside a partial view _Test.csHtml</p> <pre><code>string sortCol = "testing the sortcolumn " + grid.SortColumn; &lt;p&gt;Here is sortcolumn value :: @sortCol&lt;/p&gt; //displays --&gt; &lt;p&gt;Here is sortcolumn value :: &lt;/p&gt; @Html.Hidden("dir", grid.SortDirection); //displays --&gt; &lt;input id="dir" type="hidden" value="Ascending" name="dir"&gt; @Html.Hidden("col", grid.SortColumn); // displays --&gt; &lt;input id="col" type="hidden" value="" name="col"&gt; </code></pre> <h2>image</h2> <p><img src="https://i.stack.imgur.com/aet4P.png" alt="enter image description here"></p> <p>Thanks in advance, hope everything is clear, if not I will explain myself further</p> <h2>EDIT</h2> <p>the line :: <p>Here is sortcolumn value :: @sortCol</p> </p> <p>output :: <p>Here is sortcolumn value :: testing the sortcolumn </p></p> <p>Which is even more weird, because the variable is filled with the correct data, but just not printing the property....</p> <h2>EDIT 2 (working with viewmodel)</h2> <pre><code>public class InvoicesViewModel : BaseViewModel { public InvoicesViewModel(Controller cntrl) : base(cntrl) { } public InvoicesViewModel() { } public Double subtotal { get; set; } public WebGrid grid { get; set; } public string sortColumn { get; set; } public string help { get; set; } public IOrderedEnumerable&lt;TtCompanyInvoicelist&gt; invList { get; set; } } public ActionResult Index() { vm.grid = new WebGrid(vm.invList, rowsPerPage: 10, ajaxUpdateContainerId: "grid", ajaxUpdateCallback: "webGridUpdated"); vm.sortColumn = vm.grid.SortColumn; return View(vm); } </code></pre> <p><img src="https://i.stack.imgur.com/vPCQc.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/WJ7Wa.png" alt="enter image description here"></p> <p>In the controller you can see the value of the object is correct. In the view you can see the object is still filled correctly. But the output remains the same, the value of my hidden input is empty.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload