Hello,
I've been trying to Insert the ordered products in the salesorder database but only 1 record is being inserted.
Please Help. Below is my code:
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
try
{
int productno = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
int quantityneeded = int.Parse(((TextBox)row.Cells[0].FindControl("txtQuantity")).Text);
decimal sp = Convert.ToDecimal(row.Cells[2].Text);
int quantityavailable = Convert.ToInt32(row.Cells[3].Text);
decimal total = quantityneeded * sp;
string product = row.Cells[1].Text;
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "INSERT INTO SOrder VALUES (@CustomerName, @Address, @OrderDate, @DeliveryDate, @ProductName, @Quantity, @SellingPrice, @Amount, @OrderStatus, @Branch)";
cmd.Parameters. ...
Go to the complete details ...