I just need hints. I created 3 tables from sql database explorer. The idea when the user selects items and add them to cart, then he orders them. When he orders them the data in AddToCart table deletes, but i want to retrieve them into order table. It works with gridview, by looping through it, but when i add another item to cart before ordering, it retrieves the data from the gridview interface of AddToCart Table, but deletes whole the data successfully from AddToCart Table including the extra data.
foreach (GridViewRow g in GridView3.Rows)
TextBox myTextBox = (TextBox)(g.Cells.FindControl("TextBox1"));
if (myTextBox.Text != " ")
InsertData(Convert.ToInt32(g.Cells.Text), Convert.ToInt32(g.Cells.Text), g.Cells.Text, Convert.ToInt32(myTextBox.Text));
str = str + g.Cells.Text + g.Cells.Text + g.Cells.Text + Convert.ToInt32(myTextBox.Text);
The given code works fine when they are data in the gridview interface, i need the records or data in the data table and insert them to "Order Table".
I tried as well as i could but the problem i did not understand well. I just want to apply to data table of order instead creating a data table. However, here i tried, but did not work.
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
foreach (DataRow row in dt.Rows)
string str = " ";
InsertData(Convert.ToInt32(row), Convert.ToInt32(row), row.ToString(), Convert.ToInt32(row));
str = str + row + row + row + row;
catch (Exception r)
Label3.Text = "Unsuccessful" + "Error" + r.Message;
N.B: In the "string InsertData", i created sql connection and sql command for insert method with parameters and works fine with gridview.