I am just learning asp.net and have hit a wall with the datagrid control. I
have populated a datagrid and am able to edit fields and retrieve the new
field values from the datagrid via the UpdateCommand event but when I try
and update the database with these new values it doesn't happen. The
database isn't updated and the datagrid doesnt change.
I fill the datagrid:
SqlDataAdapter SqlDa = new SqlDataAdapter (Sql, conn);
DataSet ds = new DataSet();
DataView source = new DataView(ds.Tables);
dg1.DataSource = source;
That works fine. I have an edit column that lets you edit the data and when
i click update the update method runs fine.
the update method gets the textbox values from the datagrid then attempts to
update the datagrid/database like this:
string Sql = "UPDATE TABLE SET field1 = @DataGridValue WHERE id = xid);
SqlCommand sqlComm = new SqlCommand(sql, conn);
sqlComm.Parameters.Add("@DataGridValue, SqlDbType.NVarChar).Value =
sqlComm.Parameters.Add("@xid, SqlDbType.Int).Value = xid;
dg1.EditItemIndex = -1;
I have verified the SQL using hard coded values and I have verified that I
amretrieving the data from the datagrid correctly by writing it to a text
box on the web form, so why wont the update happen?
SOrry for the long winded post but I can't work this out after two days of