khalannz7
Centipat
Daha fazla
- Cinsiyet
- Erkek
Merhaba yeni başladım bir MVC projesi geliştiriyorum.
Bu şekilde servis yazdım ve cshtml sayfasında
Kod:
//GET
public List<Customers> GetCustomers()
{
var cstList = new List<Customers>();
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GapConnection"].ConnectionString))
{
SqlCommand cmd = new SqlCommand("sp_MusteriGetir", conn);
cmd.CommandType = CommandType.Text;
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
da.Fill(dt);
foreach (DataRow row in dt.Rows)
{
Customers customers = new Customers();
customers.musteri_id = Convert.ToInt32(row["musteri_id"].ToString());
customers.ad_soyad = (row["ad_soyad"].ToString());
customers.musteriTel = (row["musteriTel"].ToString());
cstList.Add(customers);
}
}
}
return cstList;
}
Bu şekilde servis yazdım ve cshtml sayfasında
@model List<namespace.Models.Customers>
şeklinde viewim çalıştığında verilerimi listeyebiliyorum. Her şey güzel ama aynı sayfada kullanıcı eklemek için modal eklemek istiyorum. Tıklandığında modal açılacak ve orada insert edilecek. Ama olay şu ki list olarak tanımladığım için ve bir daha @model namespace.Models.Customers
şeklinde modelime ulaşamıyorum.