在我的模型中
namespace Mvcautocomplete.Models
{
public class Product
{
public string productName { get; set; }
public int productId { get; set; }
public List<Product> GetProducts()
{
List<Product> lst = new List<Product>();
lst.Add(new Product { productName = "Andhra Pradesh",productId=1 });
lst.Add(new Product { productName = "Assam" ,productId=2});
lst.Add(new Product { productName = "Hyderabad",productId=3 });
lst.Add(new Product { productName = "India",productId=4 });
lst.Add(new Product { productName = "Bangalore",productId=5 });
return lst;
}
public List<Dose> DoseCollection
{
get
{
List<Dose> lst = new List<Dose>();
lst.Add(new Dose {doseId = 1, doseName = "A.05", prodId = new Product { productId = 1 } });
lst.Add(new Dose {doseId=2, doseName = "B.05",prodId=new Product{productId=1} });
return lst;
}
}
}
public class Dose
{
public int doseId { get; set; }
public string doseName { get; set; }
public Product prodId { get; set; }
public bool isSelected { get; set; }
}
}
在控制器中
[HttpGet]
public ActionResult Create()
{
Product obj = new Product();
return View(obj);
}
在视图中我有ProductName的文本框,它是autocomplete.now我想在更改事件的文本框中根据productName填充Dosename。
现在如何根据输入的产品名称创建和绑定复选框?