waikimmediA3
New Member
this question may be totally non-sense but I am new in MVC and Razor. Here is what I am trying to do: [*]I have a simple table "Products" from where I retrrieve all thevalues using my model. The products table has a field Id, Name,Price and StartDate. [*]I am passing the data from the Controller to the view as a List[*]In the view I have an AutoComplete field (KendoUI) where I type thename of the product[*]In the event handler of the AutoCoplete change event, I want to retrieve the "Price" of the product that has been typed in the AutoComplete textboxBelow is the code for the Product:\[code\]public class Product{ public int ID { get; set; } public string Name { get; set; } public DateTime FirstRelease { get; set; } public decimal Price { get; set; }}public class WidgetsDBContext : DbContext{ public DbSet<Product> Products { get; set; }}\[/code\]The code for my View (partial code) is below:\[code\]<div id="auto"> <p>Start typing</p> <label for="productAutoComplete">Please select procuct:</label> @(Html.Kendo().AutoComplete() .Name("productAutoComplete") .DataTextField("Name") .BindTo(Model) .Filter(FilterType.StartsWith) .Placeholder("Select the product") .HighlightFirst(true) .Suggest(true) ) <script> function productAutoComplete_change() { var gauge = $("#linearGauge").data("kendoLinearGauge"); @foreach (var p in Model) <==== HERE I WANT TO DO THE FILTERING { @: gauge.value(@p.Price); } } $("#productAutoComplete").bind("change", productAutoComplete_change); </script></div>\[/code\]CONCERN FOR VALIDATION: If I understand the basics of MVC and Razor well, then am I correct to think that the view is rendered once (during the HTTP GET) and therefore I am not able to dynamically filter the Model in Razor (but only in Javascript)? If yes, then what is the right way to do it? Thank you in advanceLefteris