G
Guest
Hi,
May be this is silly, or I just need a second pair eyes to look at this.
I am trying to get values that I have edited in a datagrid and update the
values with those values. Here is the code that I am using in my update
command.
TextBox txtProdName = (TextBox)e.Item.Cells[1].Controls[0];
TextBox txtSuppID = (TextBox)e.Item.Cells[2].Controls[0];
TextBox txtCatID = (TextBox)e.Item.Cells[3].Controls[0];
TextBox txtQtyPerUnit = (TextBox)e.Item.Cells[4].Controls[0];
TextBox txtUnitPrice = (TextBox)e.Item.Cells[5].Controls[1];
TextBox txtUnitsInStock = (TextBox)e.Item.Cells[6].Controls[0];
TextBox txtUnitsOnOrder = (TextBox)e.Item.Cells[7].Controls[0];
TextBox txtReorderLevel = (TextBox)e.Item.Cells[8].Controls[0];
CheckBox ChkDiscontinued = (CheckBox)e.Item.Cells[9].Controls[1];
string strSQL;
strSQL = "UPDATE Products SET ";
strSQL += "ProductName = '" + txtProdName.Text.Replace("'","'''") + "',";
strSQL += "SupplierID = " + txtSuppID.Text + "," ;
strSQL += "CategoryID = " + txtCatID.Text + ",";
strSQL += "QuantityPerUnit = '" + txtQtyPerUnit.Text + "',";
strSQL += "UnitPrice = " + txtUnitPrice.Text + ",";
strSQL += "UnitsInStock = " + txtUnitsInStock.Text + ",";
strSQL += "UnitsOnOrder = " + txtUnitsOnOrder.Text + ",";
strSQL += "ReorderLevel = " + txtReorderLevel.Text + ",";
strSQL += "Discontinued = " +
Convert.ToInt32(Convert.ToBoolean(ChkDiscontinued.Checked));
strSQL += " WHERE ProductID = " + e.Item.Cells[0].Text;
I am only getting values that I already have before I edited the cells. What
Am I doing wrong here.
May be this is silly, or I just need a second pair eyes to look at this.
I am trying to get values that I have edited in a datagrid and update the
values with those values. Here is the code that I am using in my update
command.
TextBox txtProdName = (TextBox)e.Item.Cells[1].Controls[0];
TextBox txtSuppID = (TextBox)e.Item.Cells[2].Controls[0];
TextBox txtCatID = (TextBox)e.Item.Cells[3].Controls[0];
TextBox txtQtyPerUnit = (TextBox)e.Item.Cells[4].Controls[0];
TextBox txtUnitPrice = (TextBox)e.Item.Cells[5].Controls[1];
TextBox txtUnitsInStock = (TextBox)e.Item.Cells[6].Controls[0];
TextBox txtUnitsOnOrder = (TextBox)e.Item.Cells[7].Controls[0];
TextBox txtReorderLevel = (TextBox)e.Item.Cells[8].Controls[0];
CheckBox ChkDiscontinued = (CheckBox)e.Item.Cells[9].Controls[1];
string strSQL;
strSQL = "UPDATE Products SET ";
strSQL += "ProductName = '" + txtProdName.Text.Replace("'","'''") + "',";
strSQL += "SupplierID = " + txtSuppID.Text + "," ;
strSQL += "CategoryID = " + txtCatID.Text + ",";
strSQL += "QuantityPerUnit = '" + txtQtyPerUnit.Text + "',";
strSQL += "UnitPrice = " + txtUnitPrice.Text + ",";
strSQL += "UnitsInStock = " + txtUnitsInStock.Text + ",";
strSQL += "UnitsOnOrder = " + txtUnitsOnOrder.Text + ",";
strSQL += "ReorderLevel = " + txtReorderLevel.Text + ",";
strSQL += "Discontinued = " +
Convert.ToInt32(Convert.ToBoolean(ChkDiscontinued.Checked));
strSQL += " WHERE ProductID = " + e.Item.Cells[0].Text;
I am only getting values that I already have before I edited the cells. What
Am I doing wrong here.