hi sir,
i am new to mvc 4,actually my problem i am retrieving quantity from one table it's come 1 by default from table1 and i am inserting table1 quantity in bascket table2 and based on column id i am trying to update bascket table2 quantity ,it is not responding ..i am giving my code below ..please help me to update quantity
(Actually my problem is Basket table quantity comes 1 from table1,i am trying to insert my default quantity in bascket table...in controller page in update action link id is processing but default quantity(what i am giving) is not processing the test object...suppose i am giving default object it is updating...please help me to solve this problem )
This is my .cs page
public class tbl_Bascket
{
[Key]
public int OrderID { get; set; }
public int ItemCode { get; set; }
public string username { get; set; }
public int Quanitity { get; set; }
public decimal Price { get; set; }
public decimal TotalPrice { get; set; }
public DateTime OrderDate { get; set; }
public string ProductName { get; set; }
}
public class tbl_BascketContext:DbContext
{
public DbSet<tbl_bascket> basket { get; set; }
}
This is my Controller page
private tbl_BascketContext dbbasket = new tbl_BascketContext();
public ActionResult update(int id)
{
tbl_Bascket test = dbbasket.basket.Find(id);
int qty = test.Quanitity;
SqlCommand cmd = new SqlCommand("update tbl_Bascket set Quanitity='" + qty + "' where OrderID='" + id + "'", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
return RedirectToAction("Bascket");
}
This is my html page
@using (Html.BeginForm())
{
@foreach (var item in Model)
{
@Html.TextBoxFor(m => item.Quanitity)
@Html.ActionLink("update", "update", new { id = item.OrderID })
}
}
Thanks for advance
Gowtham k