Try to use after the changes
public ActionResult Index()
{
ViewBag.Products = new SelectList(storeDb.Products, "ProductId", "Name","Put your selected value here");
return View();
}
Replace your value instead of this "Put your selected value here"
In view
@Html.DropDownList("Products", ViewBag.Products as SelectList, "Select Products", new { style = "width:200px" })
something this way
For the dropdown selection see the following code
<script type="text/javascript">
$(document).ready(function () {
$("#Products").change(function () {
var url = "/ControlerName/GetProductDetails";
var Products = $("#Products").val();
$.ajax({
url: url,
type: 'post',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: { id: Products },
success: function (data) {
debugger;
$('#txtPrice').text(data.d);
},
error: function () { alert('something bad happened'); }
});
});
});
</script>
Change Url controller name as per your given name
and see It's hope so data.d if not putt debugger and see where is the value