Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
{
if (!Page.IsPostBack)
{
DataTable dtToGrid = new DataTable();
dtToGrid.Columns.Add("ItemID", typeof(string));
dtToGrid.Columns.Add("ItemName", typeof(string));
dtToGrid.Columns.Add("ItemDescriptions", typeof(string));
dtToGrid.Columns.Add("ItemQuantity", typeof(int));
dtToGrid.Columns.Add("ShopQuantity", typeof(int));
dtToGrid.Columns.Add("ItemPrice", typeof(decimal));
dtToGrid.Columns.Add("ItemDiscount", typeof(int));
dtToGrid.Columns.Add("DiscountedPrice", typeof(double));
dtToGrid.Columns.Add("FinalPrice", typeof(double));
Session["dtToGrid"] = dtToGrid;
}
}
protected void Donebutt_Click(object sender, EventArgs e)
{
DataTable dtToGrid = (DataTable)Session["dtToGrid"];
DataRow drToGrid = dtToGrid.NewRow();
drToGrid["ItemID"] = itemidbox.Text.Trim();
drToGrid["ItemName"] = Itemnamebox.Text.Trim();
drToGrid["ItemDescriptions"] = itemdescriptionbox.Text.Trim();
drToGrid["ItemQuantity"] = itemquantitybox.Text.Trim();
drToGrid["ItemPrice"] = itempricebox.Text.Trim();
dtToGrid.Rows.Add(drToGrid);
GridView1.DataSource = dtToGrid;
GridView1.DataBind();
}
Right now i wanted the values in the gridview to be INSERTED into a table in the
database, i keep getting the error
Error in UpdateThe INSERT statement conflicted with the FOREIGN KEY constraint "
FK_Sales_Inventory1". The conflict occurred in database "C:\DOCUMENTS AND SETTIN
GS\JASON\MY DOCUMENTS\MY RECEIVED FILES\DRAFT_POS\APP_DATA\SKYLA.MDF", table "db
o.Inventory", column 'Item_ID'.
The statement has been terminated.